0

I have this element

<input class="input ng-pristine ng-valid ng-touched" data-cname="numberbox" type="number" placeholder="" id="rclaa9om">

I am trying with driver.find_elements_by_class_name("input ng-pristine ng-valid ng-touched")

but getting an empty list. Tried with xpath, but id="rclaa9om" is changing every time.

Here is an additional screenshotAdditional screenshot

  • Does this answer your question? [Selenium Compound class names not permitted](https://stackoverflow.com/questions/37771604/selenium-compound-class-names-not-permitted) – Matthias Apr 29 '21 at 06:40

2 Answers2

0

Looks like it's impossible to locate this element in this way.
You have to find fixed and unique relational locator of this element in relation to other element that you can locate uniquely.
Please provide a link to your page so we can find this for you

Prophet
  • 32,350
  • 22
  • 54
  • 79
0

Find element using *_by_class_name just for single class name, you can handle multiple class name using *_by_css_selector.

Please try the following approach:

driver.find_elements_by_css_selector('input.ng-pristine.ng-valid.ng-touched')
frianH
  • 7,295
  • 6
  • 20
  • 45
  • This is definitely not a correct answer! None of class names provided here are unique. Also `ng-touched` means that this element is already touched while this will not be true for locating this element by Selenium without clicking on it first! – Prophet Apr 29 '21 at 08:55
  • @Prophet in OP it is very clear that elements have several classes, it can be achieved with the css selector. Please see @Matthias comment. And for your statement *`Also ng-touched means that this element is already touched while this will not be true for locating this element by Selenium without clicking on it first!`*, it is the user's obligation to ensure that this element is already in the DOM before performing this action. – frianH Apr 29 '21 at 18:22