0

Im making a automated test but the input fields doesn't have any specific id and classes. I don't want to select everything by using xpath so i thought i was going to use the Press Keys function. After i put the text in the first input i do the function:

Press Keys LOCATOR TAB

After that i used the tab button, it goes to the next form but how do input text in the form? I know there is the input text function but it needs the locator for entering text. How can i input text without using the input text locator ?

3
  • 4
    In that case you would have to use Press Keys for pretty much every input. Try to use Input Text if it's possible in any way. If possible, ask the developer to add ids and classes or similar. Or try to find some other unique identifiers. HTML code of the related elements would help to give you the best approach.
    – asprtrmp
    CommentedNov 25, 2019 at 11:50
  • 2
    "I don't want to select everything by using xpath" - why?CommentedNov 25, 2019 at 16:23
  • @bryanOakley Because using xpath isn't in my opinon future proof, when the developers change the layout of the websites or even add one form the whole xpath is invalid.CommentedNov 26, 2019 at 13:19

1 Answer 1

2

Try to still take the xpath even if it has no specific id or class, it also works with an xpath like this: // html / body / table / tbody / tr [4] / td / center / form / table / tbody / tr [ 4] / td.

Example Input Text: Input Text [locator, text, clear = True].

Example Press Keys: Press Keys, locator, ALT

2
  • I tried avoiding xpath for future proof reasons, do you think selecting/ entering text through javascript is a better solution?CommentedNov 26, 2019 at 13:20
  • It Depends by what you want to do: if the position of your text doesn't matter for passing test, javascript could be a valid alternative, but in my opinion full xpath is a better solution to test both situations: place and text.
    – Mz98
    CommentedNov 26, 2019 at 14:08

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.