Selenium: Is it possible to combine xpath with a variable?

The xpath of my elements becomes extremely difficult to read.

// DIV [ID = @ 'main_content'] / div [2] / div [2] / div [2] / div [4] / table / TBODY / mp [2] / TD / form / FIELDSET / p [1 ]/input

It would be nice if I could store most of this as a variable and use it later as follows:

| assertElementPresent | $ {myForm} ./ fieldset / p [1] / input |

Is something like this possible? That would make my tests much easier to read!

+2
source share
2 answers

ID . 2 , xpath, , . id , . , Java- , , , HTML.

+5

:

store | //div[@id='main_content']/div[2]/div[2]/div[2]/div[4]/table/tbody/tr[2]/td/form | myForm
assertElementPresent | xpath=${myForm}/fieldset/p[1]/input

, xpaths . , , , UI-Element.

+1

Source: https://habr.com/ru/post/1746173/


All Articles