unable to locate element with Watir webdriver, Firefox, PayPal sandbox pay with PayPal - paypal

I am getting the error
Watir::Exception::UnknownObjectException: unable to locate element, using
{:id=>"submitLogin", :tag_name=>"input"}
from /Users/ktobo/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/
gems/watir-webdriver-0.9.1/lib/watir-webdriver/elements/element.rb:536:in
`assert_element_found'
when running an Rspec test using Watir webdriver with Firefox.
# select "Pay with my PayPal account"
#browser.span(:class, 'buttonAsLink').when_present.click
#browser.text_field(:id, 'login_email').when_present(15).set(hsh[:email])
#browser.text_field(:id, 'login_password').when_present(15).set(hsh[:password])
#browser.input(:id, 'submitLogin').when_present.when_enabled.click
#browser.input(:id, 'continue').when_present.click
If I execute these steps one-by-one in a console, everything's great. When running the test with run.rb, the first click action seems to fail to select the "Pay with my PayPal account" span. I'm not sure why it doesn't fail on that step. If I manually click that link after the failure, I see that the password field is not populated, so something seems to be going awry before the fourth line.

Even with the when_present calls, this is most likely a race condition if it works step by step in irb, but not when run together directly. When debugging it is often useful to put a (long-ish) sleep before the problem step just to see if you are hitting a race condition. If the sleep fixes it, then you know what the problem is and just need to figure out the right thing to wait for before clicking.
Another possibility is that this could be an issue where the browser being in the "active window" in the operating system matters. (Commands should work the same way, regardless, but this isn't always the case).
Additionally, running the test with Chrome to see if you have the same issues is also helpful in troubleshooting.
If none of this works, please update your question with an url or the html you are interacting with.
On a side note, I'm surprised that nesting when_present & when_enabled works. when enabled probably should include present? as a precondition, I'll look into doing that.

Related

Bit.cloud not showing my components tests

Bit.cloud is not showing my tests, but they are right there, and they show when running bit start locally. Sadly, the link on the no tests page directing me to learn how to add tests goes to a 404.
I the workspace is public, have a look and see here, the first link the is "tests" tab showing empty, https://bit.cloud/koodoo/koomeleon/second-charge/validation/~tests, and this link is a test for the the same component https://bit.cloud/koodoo/koomeleon/second-charge/validation/~code/eligibility/dateOfBirth/index.test.ts.
Also, side note, can I get an invite to the Slack workspace please? Again the link on the bit.cloud page goes to a sign-in page for the workspace bit-dev-community, but there is no way of registering or requesting an invite.
Please and thank you in advanced.
Explanation
The reason your tests are not being show is due to its extension.
Tests are configured to use the .spec.ts extension to work.
Solution
Having said so, rename your test to:
vaidation.spec.tsx
and it will work.
edit: forgot to add the 'x' at the end of '.tsx'

Get WebdriverIO multi-remote to work with Cucumber BDD

I am able to start multiple browser sessions in a single test using WebDriverIO's multiremote with mocha.
Next I'm trying to get WebDriverIO multiremote work with Cucumber BDD. My feature definition is simply to open a browser session and navigate to a url.
Here's my simple WDIO
Problem - the browser opens up but navigation does not occur. I have tried to enable the debugger and observe node-inspector but hasn't helped. What am I missing? Thanks for all the help.
My goal was to conduct multi-user scenario based testing through BDD. Although I haven't been able to resolve this directly via WebDriverIO I found Chimp (which uses WebDriverIO underneath) has its own flavour of session based automation.
Chimp's multi-browser testing does exactly what I wanted. Problem solved!
I'm able to write scenarios such as this without explicitly switching the user context.
Scenario: Able to browse independently
Given Alice goes to "/features"
And Bob go to "/bugs"
Then Alice sees "10" features
And Bob sees "1" bugs

Handling pop ups using selenium with perl

I want a solution for the following scenario:
In a page I am uploading an xml and while clicking on the upload button I am going to recieve an pop up for confirmation (I am able to detect this), after this again I am recieving an pop up which I am not able to detect (The page is still getting loaded in the browser ). Kindly help me to sort this out .
I have tried with many solutions for this like: get window ids,titles .
Thanks
You can you use -
$sel->get_confirmation()
This retrieves the message of a JavaScript confirmation dialog generated duringthe previous action. By default, the confirm function will return true, having the same effectas manually clicking OK. This can be changed by prior execution of thechooseCancelOnNextConfirmation command. If an confirmation is generatedbut you do not get/verify it, the next Selenium action will fail.
NOTE: under Selenium, JavaScript confirmations will NOT pop up a visibledialog.
NOTE: Selenium does NOT support JavaScript confirmations that aregenerated in a page's onload() event handler. In this case a visibledialog WILL be generated and Selenium will hang until you manually clickOK.
Returns the message of the most recent JavaScript confirmation dialog.
You should always refer to WWW::Selenium - Perl Client while working with perl and RC.
I have found what is the problem #amey ...I am tring to upload an file which is not actually not permitted due to some security issues with firefox... There was actually an work around for this
http://cakebaker.42dh.com/2006/03/29/file-upload-with-selenium/
.....Which will not work with latest Selenium RC with Firefox since firefox have removed the support for enablePrivilege
https://support.mozilla.org/en-US/questions/944433.
So it is a mandate to shift to WEBDRIVER it seems.............
http://git.erp5.org/gitweb/erp5.git/commitdiff/06898bbfae4f238b7e79ce05048646529216064e
Thanks for your support....
my solution was using the function:
$driver->execute_script("Events.invokeEvent('UserDetailPage:UserDetailScreen:UserDetailToolbarButtonSet:UserDetailToolbarButtons_DeleteUserButton_act', true);");
analyzing what the javascript code does when the Accept button was pressed. and executing that code in the function.

Using Turbolinks with Selenium IDE

When I run my selenium test without the turbolinks gem installed in my Ruby on Rails app, the tests pass. When I include turbolinks, the tests fail. For example if the test starts off
Open /
clickAndWait link=Sign in
type id=session_email any#example.com
Then I will get an error
"[error]Element id=session_email not found.
When I look at the page source, the session_email id is still there with turbolinks installed. I found this page, http://www.digitalkingdom.org/rlp/tiki-index.php?page=Selenium+And+Javascript, which seems to indicate there could be a problem with detecting the page has fully loaded.
Is there away to fix this without changing hundreds of lines in my test suites? If not, is there a reliable selenium method that can test that a turbolinked page has fully loaded?
After some help with the github turbolinks-compatability project, I am able to provide a partial answer to this question.
If the turbolinks gem is being used, then you will need to modify your selenium test cases in order to make sure the page is really loaded. For example, if your test has the following code in it
Open /
clickAndWait link=Sign in
type id=session_email any#example.com
then it needs to be modified to
Open /
click link=Sign in
waitForElementPresent id=session_email
type id=session_email any#example.com
There are a number of "waitFor" modifiers you can used, depending on what is the feature on the page you want to test next.
However, if the test involves a javascript pop up, then you should not add a waitFor command. So for example if you have at test like
clickAndWait link=Delete
assertConfirmation Are you Sure?
you should not modify the code. Indeed adding a waitFor test hangs execution in the case of javascript popups.
This solution involves line-by-line manual modification of the code. I have opened up an issue on the Selenium Users group to see if there is some better way to handle this problem.

Selenium test on a GWT app - request not sent to server

I'm writing a selenium test for a GWT app. It uses the mouseover/
mousedown/mouseup approach to click pushbuttons. It clicks the Login
button of my app, which calls up the div containing userid and
password entry fields, and that works just fine. It then enters a userid and
password, then clicks the Submit button for the login form.
If I run it slowly, I can see the button click, but the request never
gets sent to the server (I'm watching the wire).
In fact, if, while the selenium IDE is still open, I manually click
the button, the request is not sent. If I then close the selenium IDE
and click the button, the request goes through fine.
Anybody seen this one? It seems really strange.
Update:
Firebug shows a script error. Apparently, the selenium script has some conflict with the GWT script. Here's the beginning of the error, but the whole thing is quite lengthy:
[Exception... "'com.google.gwt.core.client.JavaScriptException: (TypeError): result is null fileName: chrome://selenium-ide/content/recorder.js lineNumber: 74 stack: ([object XMLHttpRequest],"POST","http://localhost:8080/login",true)#chrome://selenium-ide/content/recorder.js:74 XPC_SJOW_CallWrapper((function (url, windowName, windowFeatures, replaceFlag) {if (self.openCalled) {return self.originalOpen.call(window, url, windowName, windowFeatures, replaceFlag);} else {self.o
Okay, I found the answer. It's a little embarrassing, but it provides the answer and it's funny, too. I'll share the answer so that you can avoid the problem, and perhaps have a laugh at my expense. :)
The answer is that you have to compile to OBF instead of PRETTY. All the associated links are listed below. They fully explain the problem, and how to avoid it.
What's funny about this? Well, as I was going through search, I finally hit upon the first link below. Almost immediately, I realized, or at least had a sneaking suspicion, that I had solved this problem before. Sure enough, the original question was posted in October, and I was the poster. So, I got an answer before, and completely forgot. Ah, well. Hope the answer helps someone, and my comic misfortune brightens your day.
http://clearspace.openqa.org/message/50170
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/5d6a9c448a82b916/af62e5877237b107?lnk=raot
http://code.google.com/p/google-web-toolkit/issues/detail?id=2861
Maybe you could try clickAt or mouseDownAt, they seem to perform a bit differently.