Calabash iOS - How to clear text in a webview - cucumber

clear_text doesn't work for me when testing a webview. Does anyone know of a different method for webview/cordova apps? The locator I'm using is "webView css:'input#username'" but that seems to be fine as enter_text is working.
Any suggestions?
Thanks,
Lewis.

Thanks but set_text("webView css:'input#username'", "") didn't work. I ended up using the solution you mentioned here
Thanks.

set_text("webView css:'input#username'", "")
You might also try using the WebView JavaScript API

When I had a similar problem, I ended up using something like this :
Then /^I clear a field with "([^\"]*)" text$/ do |name|
name = set_value name
element = query("UITextFieldLabel text: '#{name}'")[0]
touch(element)
wait_for_keyboard
name.to_s.split('').each do |c|
keyboard_enter_char 'Delete'
end
end
Details are in here: Clear field with calabash-ios

Related

Mongoid pagination

I tried
#posts = Post.page(params[:page]).per_page(10)
and
#posts = Post.paginate(:page => 1, :per_page => 10)
but neither method works
undefined method `page' for Post:Class
undefined method `paginate' for Post:Class
How do you do pagination with mongoid?
You should use Kaminari https://github.com/amatsuda/kaminari
This works fine for me:
#posts = Post.paginate(:page => 1, :limit => 10).desc(:_id)
desc(:_id) is added so that latest posts could be listed first.
Still using will_paginate is also okay.
This thread has same issue: undefined method `paginate' for Array on Rails 3 with mongoid
The main point to fix the error is to add this line before the controller call paginate library:
require 'will_paginate/array'
It should be added to default config file if you use mongoid for the whole project.
Hope the explanation helpful.
Reference from origin gem source: https://github.com/mislav/will_paginate/wiki/Backwards-incompatibility at "WillPaginate::Collection" section.
P/S: this is just a work around if your query is not very large. If you want better performance, let's try mongoid-pagination gem, custom will_pagination gem or another pagination gem which supported Mongoid like kaminari.
A bit late, but for anyone else looking, I found 'will_paginate_mongoid'
https://github.com/lucasas/will_paginate_mongoid
Really straight forward and lets you simply do
collection.skip(20).limit(10)
Use the following gem.
Very helpful.
https://github.com/lucasas/will_paginate_mongoid
To update a bit the answers, now exists the Pagy gem, also much more performant (cpu/mem) than will_paginate and kaminari. This is a migration guide
silly thing, but it worked for me in sinatra after i added require 'mongoid-pagination'
to app.rb
Posting several years later, in case someone else faces the same challenge.
kaminari-mongoid was released in 2016, and is currently maintained.
https://github.com/kaminari/kaminari-mongoid
All the goodness of Kaminiari for Mongoid, including appropriate handling of Mongoid::Criteria results, which was possibly the cause of the OP's error.

Setting id dynamically in jade / id interpolation

I've tried all the permutations I can think of but alas with no success.
I am trying to set an id dynamically in a jade template.
#{page.name}(data-role= 'page', data-theme= 'c', data-url='#{"#"+page.name}')
I wondering if it's actually possible.
Anyone know how to do this?
If some one knows, please help me out - before all my hair falls out :(
For anyone looking for the answer to this:
Answered kindly by TJ the developer of express.
div(id=myPassedId),
div##{myPassedID}( isn't supported because it would be super ugly
The suggestions here did not work in my scenario...
The format that worked for me:
x-task-id!="<%= id %>"
Ugly, but functional.
Nowadays you can also use a template literal:
- const page = { name: 'foo' }
#{page.name}(data-role="page" data-theme="c" data-url=`#${page.name}`)
Output (using Pug 2.0.4):
<foo data-role="page" data-theme="c" data-url="#foo"></foo>

Determining if a link exists w/ Cucumber/Capybara

I want to verify that a link with a specific href exists on a page. I am currently doing I should see "/some-link-here" but that seems to fail. How can I make sure that link exists without having to do click + I should be on "/some-link-here" page?
You will need to add custom step
Then /^"([^\"]*)" should link to "([^\"]*)"(?: within "([^\"]*)")$/ do |link_text,
page_name, container|
with_scope(container) do
URI.parse(page.find_link(link_text)['href']).path.should == path_to(page_name)
end
end
You can use the step like Then "User Login" should link to "the user_login page", user_login is the name of your route
I used jatin's answer, but have a separate scoping step:
When /^(.*) within ([^:]+)$/ do |step, parent|
with_scope(parent) { When step }
end
Then /^"([^\"]*)" should link to "([^\"]*)"$/ do |link_text, page_name|
URI.parse(page.find_link(link_text)['href']).path.should == path_to(page_name)
end
Then I have this in my test:
step '"my foods" should link to "food_histories" within ".tabs"'
And this in my paths:
# note: lots not shown
def path_to(page_name)
case page_name
when /^food_histories$/
food_histories_path
end
end
This is what I have done myself, quite simple but it does mean you are hardcoding your url which to be honest is not ideal as it makes your test very brittle. Especially if you are using 3rd party URL's!
But if you are using a url that you manage and are happy to maintain this test then go for it.
Then /^the link is "(.*?)"$/ do |arg1|
page.should have_xpath("//a[#href='" + arg1 + "'][#target='_blank']")
end
I first landed here, when looking for a solution and thought I would give an updated answer. It depends what your capybara syntax is, but using the matcher has_link? you could write for href = /some-link-here and link_text "Click Me"
expect(page).to have_link("Click Me", href: '/some-link-here')

MgTwitterEngine Iphone

Hello
I am using mgtwitterengine in iphone to call twitter API. I want to retrive followers name
in my iphone.
I used textfield.text=[_engine getFollowersIncludingCurrentStatus:YES]; but it is not showing correct result. it only show some alphabets...
could anyone tell me how to do this.
you are using
NSLog(#"%#",[_engine getFollowersIncludingCurrentStatus:YES]);
getFollowersIncludingCurrentStatus not responding the result, it returns connection identifier which is DF387EE5-05CE-40E3-A12D-4D016C581233 in your case
your API response will come in this method
- (void)userInfoReceived:(NSArray *)userInfo forRequest:(NSString *)identifier
this is delegate method you have to add this in your class.
[_engine getFollowersIncludingCurrentStatus:YES];
use like this it may help you, i got the values and printing on console

sharepoint: Using a Content Editor Web Part this error occurred:"Cannot retrieve properties at this time."

I have a content editor web part. Whenever I edit the content and then click save, the following errors occurred:
"Cannot retrieve properties at this time."
"Cannot save your changes"
How do you fix this?
I tried googling it.. there are some similar cases but not exactly the same. I tried this link:
www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/MS-SharePoint/Q_21975446.html
and this one:
support.microsoft.com/kb/830342
and this one:
blogs.msdn.com/gyorgyh/archive/2009/03/04/troubleshooting-web-part-property-load-errors.aspx
I found the answer!! apparently using mozilla firefox it worked. Then I found out that there is a javascript error in IE, this javascript error doesnt happened in firefox. how ironic!
Are you doing anything to modify the URL in an HTTPModule? I ran into this problem on a publishing site where a module was hiding the "/pages" part of the URL. Modifying the CEWP via the page when accessed w/o the "/Pages" wasn't working, but with the "/Pages" it was.
Example:
Got error: http://www.tempura.org/webpartpage.aspx
Worked: http://www.tempuri.org/pages/webpartpage.aspx
I don't see how this is an answer -- "don't use IE".
In my case (and apparently many others) it has something to do with ISA + SharePoint + host headers. I will post the fix if I find one.
I have had problems with this before and have found recycling the Application Pool often corrects the problem.
Rodney
IE8 -->
Tools --> Compatiblity View Settings --> CHECK THIS : Display All Websites in ....
If you are editing a webpart page, make sure that it is checked out. Sometimes the document library the webpart pages are in will have a "force check out to edit" option and it will give you errors if the webpage itself isn't checked out.
I had this same error recently. In javascript, I had written some prototype overrides (see examples below) to add some custom functions to the string and array objects. Both of these overrides interferred with SharePoint's native JavaScript somehow in IE. I removed the references from the master page and this issue was FIXED. Currently trying to find a work-around so I can keep them because things like the string.format function is very nice to have...
//Trim
if (typeof String.prototype.trim !== 'function') {
String.prototype.trim = function(){
return this.replace(/^\s+|\s+$/g, '');
}
}
//Format
String.format = function() {
var s = arguments[0];
for (var i = 0; i < arguments.length - 1; i++) {
var reg = new RegExp("\\{" + i + "\\}", "gm");
s = s.replace(reg, arguments[i + 1]);
}
return s;
}
I also faced the same problem. Finally it worked for me using url /Pages/Contact-Us.aspx instead of clean URL. It worked only with IE browser. Don't know why this was happening but anyhow it worked with me.
Use IE browser
Use Pages in the URLinstead of clean URL.
to me,
compatibility mode in IE8, to work

Resources