-2

I am new at testing so my apologies in advance if my question sounds a bit primary.

I use Selenium and Java to write tests, I need to find an element by more than one criteria.

I saw this question on stackoverflow which is exactly what I meant, but the answers do not work for me as I do not know what is //input[(@id='id_Start') and (@class = 'blabla')] and how to generate it.

Community
  • 1
  • 1
LoveLovelyJava
  • 735
  • 4
  • 9
  • 21

1 Answers1

0

It is an XPath. Everyone seems to be in love with them for some reason but they are slower and more error prone than other methods and used many times when it's not necessary. I think people favor them because you can right-click and choose Copy XPath and paste in your code. The problem is when you code that way it's very fragile. Minor changes in the DOM can break your script.

I would suggest that you learn the standard methods well... prefer ID, name, tagName... if those aren't available or you need something more complicated, use CSS selectors. When all else fails, consider XPath. Refer to the Selenium wiki for basic information on each of these methods along with googling blogs, etc. for more detailed descriptions.

JeffC
  • 22,180
  • 5
  • 32
  • 55