robotframework / SeleniumLibrary

Web testing library for Robot Framework
Apache License 2.0
1.38k stars 758 forks source link

Locate Element failure #211

Closed gurusv closed 10 years ago

gurusv commented 11 years ago

Hi ,

I am trying to automate a click link operation on a Tree element using RobotFramework-Selenium2Library.

with help of FireBug and XPath checker I got the Xpath for the Tree element and tried to locate the element using Selenium IDE. Selenium IDE highlights the object on the page without any problem.

Same when tried using RobotFramework it fails to locate the element and throws an error saying

FAIL : ValueError: Element locator 'xpath=//a[@href='#0-3']' did not match any elements.

XPATH is simple -> xpath=//a[@href='#0-3']

I have tried with FireFox 20.0.1 and IE 8.

I am new to selenium and Robot Framework and not finding any clue . I am missing anything? Expecting your help in this regard.

Robot Framework 2.7.7 (Python 2.7.3 on win32)

code snippet:

Open Browser http://<1.2.3.4>:58080/test browser=ff Set Selenium Timeout 10 Maximize Browser Window Input Text id=name admin Input Password id=password changeme Click Button //button[@type='submit'] Click Link xpath=//a[@href='#0-3']

ombre42 commented 10 years ago

Sorry no one replied to this. It sounds like the problem could be timing. Perhaps the element you are finding with Selenium IDE does not yet exist in the DOM when Click Link executes. Try putting one of these before the Click Link:

Wait Until Page Contains Element    xpath=//a[@href='#0-3']
Wait Until Element Is Visible    xpath=//a[@href='#0-3']
gurusv commented 10 years ago

Thanks for your help..I got this suggestion and it worked //a[contains(@href, '#0-3')]

ombre42 commented 10 years ago

I am glad you got it working. Something still sounds a little strange here. I would be curious to see what the output of Get Element Attribute xpath=//a[contains(@href, '#0-3')]@href would be. Feel free to re-open this if you think there is an underlying issue here that can be resolved in Selenium2Library.