Reputation: 15
I am new to robot framework and learned few basics of robot framework. when i tried to create a new account in facebook , i have used id element of "create new account" but everytime new id is generated when its open an new page. can someone help to make me understand how to click a button when id is dynamic.
*** Settings ***
Library SeleniumLibrary
*** Test Cases ***
facebooklogin
open browser https://www.facebook.com/ firefox
maximize browser window
set selenium timeout 10s
click button id:u_0_d_si
Error message : Button with locator 'id:u_0_d_si' not found.
Upvotes: 0
Views: 2089
Reputation: 416
sometimes this works great on dynamic elements:
${element1}= Asign Id To Element contains...etc
Execute Javascript arguments[0].click(); Arguments ${element1}
Upvotes: 0
Reputation: 2813
Just use proper locator strategy of the element, since you have used the id attribute of element, but if you refresh the page every time it will change, meaning id attribute value is dynamic, where as you can go for text of the element to identify it every time uniquely.
*** Test Cases ***
Create new facebook account
Open Browser https://www.facebook.com/ firefox
Maximize Browser Window
Set Selenium Timeout 10s
Click Element xpath:.//a[text()="Create New Account"]
Upvotes: 0
Reputation: 11
A fast alternative that I found is that you can open this link : https://www.facebook.com/login/web/ and then:
SeleniumLibrary.Wait Until Element Is Visible
xpath://a[contains(text(),'Sign up for Facebook')] 10s
Click Element xpath://a[contains(text(),'Sign up for Facebook')]
Upvotes: 0