0

How about using CSS selector in Selenium Python if I am not getting id or name or class of that HTML element ? How about preferring CSS in comparison to XPath?

0

1 Answer 1

5

No idea what you are trying to ask here. I can only take a guess.

How about using css selector in Selenium Python if I am not getting id or name or class of that html element ?

If you are testing a complex web application, you have to learn CSS Selector and/or XPath. Yes, other locating methods are somewhat limited.

How about preferring CSS in comparison to xpath?

Generally speaking, CSS Selectors are always in favor of XPath, because

  • CSS Selectors are more elegant, more readable
  • CSS Selectors are faster
  • XPath engines are different in each browser
  • IE does not have a native xpath engine

However, there are situations XPath is the only way to go. For example

  • Find element by its text
  • Find element from its descendants (if there are no other better methods)
  • Few other rare situations
1
  • @selenium_user: Do you have any feedback on this? Did it work for you?
    – Yi Zeng
    Apr 23, 2014 at 8:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.