0

I have a hyperlink on my webpage.It matches when I find element through Xpath. When I execute the same it says:

.//span[@translate='home.onboarding.name'] did not match any elements

I have tried the same using selenium webdriver and it executes. Please help me in converting the same syntax in Robot Framework using Selenium2library or any alternate option to find hidden elements. Please check screenshot in the next link for reference.Xpath and Inscpect element image for reference Any help would be appreciated. Thanks.

Selenium code example:

element = driver.find_element_by_xpath("//span[@translate='aside.nav.Operate.OnBoardDevices']")
driver.execute_script("$(arguments[0]).click();",element)

RF Code example:

Click Element   xpath = //span[text()='CAMBIUM'] 
Sleep   3
Click Element   xpath = //span[@translate='home.onboarding.name']
jim
  • 906
  • 7
  • 14
Auto-learner
  • 1,411
  • 7
  • 26
  • 43
  • So what is your error exactly? "not visible" or "did not match"? Please show us the robot code as well. Thanks – jim May 10 '16 at 15:53
  • Open Browser ${cnMaestro_URL} ${Browser_Chrome} Click Button Sign In Input Text name=email ${cloud_Username} Input Text name=password ${cloud_Password} Click Button Sign in Click Element id=accountDetails-Menu Click Element xpath = //span[text()='CAMBIUM'] Sleep 3 **bold**Click Element xpath = //span[@translate='home.onboarding.name'] Input Text name = claimdevice 42-89-56-67-B0-0C,D8:D8:5F:3B:57:0E Click Button Claim Devices Sleep 5 Choose Cancel On Next Confirmation Close Browser – Auto-learner May 10 '16 at 16:16
  • Jim xpath = //span[@translate='home.onboarding.name'] is the one which I am trying to click .This element is clickable through webdriver which I have mentioned in 1st comment – Auto-learner May 10 '16 at 16:17
  • What is the actual error text? – jim May 10 '16 at 16:20
  • @jim following is the error which I am getting ValueError: Element locator 'xpath = //span[@translate='home.onboarding.name']' did not match any elements. Can you please check the Xpath and inspect element image for reference in the 1st comment for more information .. Thank you very much for your answers – Auto-learner May 10 '16 at 16:24
  • Have you verified (visually or by screenshot) that driver is at the correct page for this failing step? – jim May 10 '16 at 17:12
  • I suspect this is a timing issue if you think the element is visible at the time of failure. Do you have the test capture a screenshot on failure? Have you tried a sleep before asserting the element as a quick test to rule this out? – shicky May 10 '16 at 17:17
  • I have checked by capturing the screenshot and it was blank page(gave sleep time for 20 seconds).But the success ratio of page to load takes 5-20seconds randomly. Is there any way that I can execute next keyword after element is visible. – Auto-learner May 10 '16 at 17:34
  • Yes, there is. Wait Until Element Is Visible http://robotframework.org/Selenium2Library/doc/Selenium2Library.html#Wait%20Until%20Element%20Is%20Visible . Is your application by any chance written using Angular? – jim May 10 '16 at 18:09
  • @jim Yes my application is written in Angular JS . but your comment solved my question .I have executed 10 times and it didn't fail. thanks a lot . I have addded this keyword before Wait Until Element Is Visible xpath = //h1[text()='Welcome'] 60 – Auto-learner May 10 '16 at 21:42
  • I have posted a formal answer. Please mark it correct if it indeed solved your problem. Also, have a look at Extended library, that I have mentioned. – jim May 11 '16 at 06:36
  • Thanks for your answers @jim . I will go through extended selenium2library – Auto-learner May 11 '16 at 06:38

1 Answers1

1

You can use Wait Until Element Is Visible keyword to verify that element is indeed available for clicking.

However, as you have mentioned in the comments that your application uses AngularJS, I have to suggest that you switch from Selenium2Library to ExtendedSelenium2Library. It has native support for waiting for elements in Angular.

jim
  • 906
  • 7
  • 14