Answered

Use text value of a variable in web locator

The use case is we have a list of notes with a 'delete note' button next to each single note message. The text case first generate a random string and store it in a variable called 'note_text'. We then want to create a new note with this text, and after delete it use web locator.

We prefer to locate this 'delete note' button with something similar to:  div contains text that equal the the value of the variable 'note_next' -> child delete button in this div.

The question is how can we pass this test case variable to the web locator? 

0
1 comment
Avatar
Joseph Hamdan

Hi Dhrupa,

You can create a web locator with a dynamic XPath that takes a variable value which is defined in your test case.

For example, //div[contains(text(),'Sample Text')]

In a web locator, it becomes:

//div[contains(text(),'@variable_value')]

If you are using Set_Var command to specify the random string, you can use the same variable name you used in Set_Var step in the XPath above. Once the step with the XPath is reached, the part "@variable_value" will be replaced with the value from Set_Var.

Regards,

Subject7 Team

1
Comment actions Permalink

Please sign in to leave a comment.