vendredi 10 août 2018

Robot Framework - Getting a Text of a Div with no ID

I am using robot framework,

I have to verify that a users name is the same on one page and other page,

There is multiple different users, i need to get the Text of the div the users,

Right now the name is hard coded but when the user dissapears after being assign to something, the test will fail although everything is working,

*** Settings ***
Library  SeleniumLibrary

*** Variables ***
${User_Div} =  //*[@id="app"]/div/div[1]/div[3]/div/div/div[1]/div[2]/div/div[1]
${User_Name} =  John Doe


*** Keywords ***
//..more code here irelevant..//
Validate User Name
    Click Element  ${Resident_Div}
    page should contain  ${Resident_Name}

This is the value of the div

<span><!-- react-text: 116 -->John<!-- /react-text --><!-- react-text: 117 --> <!-- /react-text --><!-- react-text: 118 -->Doe<!-- /react-text --></span>

What I am trying to do is Get the text of ${User_Div} on load of the div and store it in this variable, to verify the next page contains the same page.

Note: The web app is designed with react, there is ID on the div.

Update:

I will try to make it clearer here

Look for ${User_Div}
Get Text value of ${User_Div}
Assign text value of ${User_Div} to ${User_Name}
the outcome should be ${User_Name} == ${User_Div} text

Aucun commentaire:

Enregistrer un commentaire