Ruby Cucumber: Selenium Webdirver - IE 11 link flashes, cannot click on - ruby

I am experiencing IE browser links flashing issue when I run test automation written in Ruby Cucumber using Selenium WebDriver.
Scenario: Navigating to Reporting home page.
Given I see menu Reporting available.
When I navigate to "Annual Reporting".
Then I see the correct header on Annual Reporting page.
home_page.rb (Approach 1: using page_object)
link(:annual_reporting_link, :id => 'annualReportingLinkId')
def go_to_reporting
mouse_over_home
wait_until(5) do
annual_reporting_link
end
end
Result: Could not click on the link because of the link flashing.
Then I tried the following (Approach 2: Using send_keys)
#browser.find_element(:id, 'annualReportingLinkId').send_keys :return
and
#browser.find_element(:id, 'annualReportingLinkId').send_keys(KEYS.ENTER)
but it did not work either. I am getting this error when run the test:
Selenium::WebDriver::Error::ElementNotVisibleError: Cannot click on element
The HTML:
<div id="homeMenu">
<ul>
<li class="has-sub"><a class="homeButton" href="/report-web"></a>
<ul id="homeLinks">
<li id="report1LiId"><span id="report1LinkName" class="disabledLinksText">Report 1</span></li>
<li id="report2Id"><span id="report2LinkName" class="disabledLinksText">Report 2</span></li>
<li id="annualLiId"><span id="annualReportingLinkName">Annual Reporting</span></li>
<li id="administrationLiId"><span id="administrationLinkName" class="disabledLinksText">Manage Users</span></li>
</ul>
</li>
</ul>
</div>
Test automation is able to expend the home menu, which contains sub-menus - hyperlinks. But after mouse_over_home (the home menu), the sub-menu started flashing. I need to click on "annual_reporting_link" to go to this reporting page, but because of flashing, the test automation cannot click on it at all.
Anyone has a solution that worked for you? Please share your solution.
Environment:
Ruby: 1.9.3
Cucumber: 2.1.0
Selenium Webdriver: 2.53.4
page-object: 1.2.0
IE: 11

I've had this issue before using Selenium Webdriver and IE. I found that it was a bug between my version of IE and Selenium Webdriver.
When I experienced this problem, I put a break-point before the link was clicked and debugged the test, I then manually tried to click the link in IE and I was still unable to do so 9 times out of 10 because of this bug, the link was simply ''flashing'' and unresponsive.
I'd recommend upgrading your version of Selenium Webdriver to version 3.0.0, that should fix the problem.
If you don't want to make the jump to Selenium Webdriver 3.0.0, You need find out the exact version of IE 11 you're using. Try to upgrade or downgrade your version of IE 11, this should also fix the problem, but you may find you're stuck on a version of IE 11 until you upgrade to Selenium Webdriver 3.0.0.
Antoher solution is to set the persistent hovers to false within your IE profile, something like this:
profile = Selenium::WebDriver::IE::Profile.new
profile['enablePersistentHover'] = false
driver = Selenium::WebDriver.for :IE, :profile => profile

Related

A minimal Nightwatch test doesn't work with Firefox 57

Here is a reproduction repo:
https://github.com/anatoliyarkhipov/nightwatch-firefox
It's a clear installation of nightwatch and webdriver-manager. The test opens http://example.com, clicks on the link and checks some content on the next page.
The problem is that if I run it in Firefox, it fails on the first step where we check that <body> is visible. If we change firefox to chrome in nightwatch.conf.js, then the test will pass.
I run it on Windows 10, Firefox 57.0 (64-bit).
What am I doing wrong?
You are missing path to the driver files in your config files
https://github.com/IvanNaumenko/test-project-nightwatch-cucumber
Hey!
This is nightwatch with cucumber. Download and write tests like in example here. You won't regret
Make sure you have the right version of geckodriver. Get the latest here: https://github.com/mozilla/geckodriver/releases

Capybara : Ruby : not detecting popups

I have an application where when i click a link (link1) it opens popup, below is the code for the popup
link1
i tried using
page.driver.browser.window_focus page.windows.last.handle
also i tried using
new_window = window_opened_by{click_link link_text}
within_window new_window do
click_link 'overridelink'
end
both of them are not working so finally i tried to get the windows ids
print page.driver.browser.window_handles
result
["ccc7074b-dad0-472f-b134-a6c72e08f7a4"]
so it looks like capybara is not even detecting second window
can you guys help me in this issue & also if there are any work arounds
You've probably run into the following issue with selenium-webdriver - https://github.com/SeleniumHQ/selenium/issues/1273

Form not submitted on click using watir-webdriver in Chrome

I am using ruby/cucumber/watir-webdriver and the page-objects gem to run my tests. My tests are usually run in firefox but decided to give chrome a try. While the click works in firefox it does not in chrome. Here is the sample html code:
<form id='test-form' method='post' class='validate-inline'>
...
<div class='margin-top'>
<input class='btn' data-disable-with='wait...' type='submit' value='Submit Form'></input>
</div>
</form
In my class page I have the button declared as the following:
button(:submit_form_btn, :value => 'Submit Form')
And call it this way:
submit_form_btn_element.when_present.click
I do see the button text change to 'wait...' for a few seconds then returns to 'Submit Form' but does not seem to submit the form. As mentioned before it works with firefox and when clicked manually. Just seems to be an issue in Chrome. Any ideas how to get around it?
I tried clicking the div, and tried clicking the button twice but same issue.
As always your help is appreciated. Thanks.
I know this question is little old now, but I thought I'd post in case this helps anyone.
Most of the times I've run into similar issues, it was caused by an update to Chrome that caused issues with the version of the watir-webdriver gem (or one of it's dependencies) or with the version of chromedriver that I was using. I've had success in the past by updating my gems and chromedriver and the other times I've had to roll back the browser version to the previous release.
It's not ideal to be testing on an older version of chrome but it worked fine as a stop gap until the issue was fixed.
If you do go for the previous version of chrome approach, make sure to log a bug ticket if there isn't already one there.

Invalid Xpath 2 error for 'Click' selenium function

I have ran a test using Selenium IDE 2.3.0 and copied the Junit4/Remote control script into the Eclispe Classic 4.2.2 and started running my code as 'Junit4'.
I see the following error:
Invalid Xpath 2
The selenium command in Eclipse for Xpath is:
selenium.click("//input[#value='Search Equipment']");
I tried copying the Xpath using Firebug which was:
/html/body/section[2]/section/div/div/div/form/div[2]/div[2]/div/span/input
But I get the same error.
start selenium record and enter some thing to ur textbox or if its a button click the button then click stop.you can get the correct xpath by going to target in the relevant step in selenium IDE.use last xpath.
As per your question, i understood that you need to click on the button "SearchEquipment".
So try with this xpath :
selenium.click("//span[#id= 'rba-keyword-submit']/input")

Unable to "click" in recent webdriver release on FireFox

I am facing intermittent issue in Clicking on a button or a hyperlink on Firefox.
I am using webdriver version 2.27 and FF17.
The buttons are simple html button -
<input class="btn" type="button" title="AddP" onclick="navigateToUrl('/p/tyy/SelectSearch?addTo=006y67&retURL=%2F00999yu2Boy9','MM_LIST','addP');" name="addP" value="Add P">
I use locator as : name=addP
For hyperlinks I use locator as : link=hyperlinktext
The Click will not fail with any exception, it will simply highlight the button or link, but not perform the actual click.
The frequency of failure is once in 3 times.
Thanks
Sky
Upgrade to at least Selenium 2.28. There were some bugs for Firefox 17 before that.
Here is what i found :
Issue 1: I was using By.linkText("test test").click which should have been By.partialLinkText("test test").click . Thanks to stackoverflow for the answer.
Issue 2: I rewrote the css locators for failed button to start from class of some parent above.
For e.g. instead of
css=input[name='j_id0:j_id2:j_id3:j_id4']
I am now using
css=.individualPalette input[name='j_id0:j_id2:j_id3:j_id4']
And it works all the time. I am not sure why??
I am still to rerun my scripts couple of more times to be sure these helps.

Resources