Invalid Xpath 2 error for 'Click' selenium function - xpath

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")

Related

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

Selenium Firefox 19 CSS Menu Click Not Working

Using Selenium, with an earlier combo of the webdriver (2.28.0) and Firefox (pre-19), the following code worked.
driver.get("http://www.haemonetics.com/en");
driver.findElement(By.linkText("LOGIN")).click();
driver.findElement(By.linkText("Haemonetics")).click();
With webdriver 2.31.0 and Firefox 19.0.2 the code does not work and I receive a NoSuchElementException for the second findElement.
I tried using xpath which doesn't work for Firefox but does work for Chrome and IE, which are part of the same test suite.
Any thoughts or another way to accomplish the same thing? I would prefer to use the same code for the mentioned browsers.
Not sure if it was a typo on your part, but it should be "find_element" instead of "findelement", at least it's so in 2.31 to my knowledge.
Try
driver.find_element_by_link_text("LOGIN")
if that doesn't work, post your HTML code so we can possibly construct a working Xpath.

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.

How to work with Xpath visualiser

I have downloaded XPath Visualizer Version 1.4 folder from
http://www.huttar.net/dimitre/XPV/TopXML-XPV.html link compatable to IE .I'm currently using Internet Explorer 8,then opened 'XPathMain.htm' file from the folder that is downloaded and tried to browse 'authors.xml' and gave xpath expression as //* and hit 'process file' button but i didnt get any output. Do i need to configure anything in my browser or include any jscript as such. There is nothing as such mentioned in 'read me' file.
You can use Xpath Explorer
Also check this site for online XPATH evaluator.
If have budget, go for XML SPY.

Watin support for IE 9 - Part 2 (Specific)

Watin Runtime Version: v2.0.50727
Browser: IE 9
I have found a specific issue:
BaseIEController.IE.Element(fieldname).Exists throws an Exception as under:
"It's not possible to find the element because no element finder is available."
The fieldname here is a Regex for a link, a simple Regex where the Link's Id is passed.
This works with IE 8.
I cannot use the Final Release of Watin 2.0 since the LogonHandler is not complete (not fully functional as mentioned in the Release Document. I have tried testing it as well).
Any idea on how I can get this Element thingy to work??
Thanks,
K
Today I have upgraded to IE9 on my windows 2008 system and run all the 745 WatiN 2.x unittests and found no issues (accept for one dialog handling the javascript::return dialog fired by onbeforeunload event).
Let me know if you have more specific info/ code example will help too to reproduce the issue you reported.
Jeroen
Lead dev WatiN
Thank you for the response. Firstly, Awesome job with Watin :)
I am trying to run the test using VS2008 and IE 9. The goal is to Click a Link but before that I am verifying if the Link is exists.
The Regex I use for this link is LnkSignIn = new Regex(".*linkSignIn$");
I then use BaseIEController.IE.Element(fieldname).Exists where the fieldname is an Attribute Constraint (in this case the Regex). This would return a true or false if the Link is found. If found, I then click the Link. Instead it returns the Error MyTestInitialize threw exception. WatiN.Core.Exceptions.WatiNException: WatiN.Core.Exceptions.WatiNException: It's not possible to find the element because no element finder is available.. at WatiN.Core.Element.WaitUntilExistsOrNot(Int32 timeout, Boolean waitUntilExists)
...
This works just fine with IE 8. Further, I noticed that if I change Element to Link, it returns true. But since this is a generic method, I want to keep it as element. Hope this helps. Please let me know if you need more information. Thanks.

Resources