Home > Net >  Selenium Python - Finding Elements by Class Name With dynamic parameters
Selenium Python - Finding Elements by Class Name With dynamic parameters

Time:10-05

I was wondering if there is any way to find element by class name if the class name have a static param and dynamic param, I'll explain: I got

< class="**dataset-selection-dialog-actions** *ng-tns-c139-19*" >

the 'dataset-selection-dialog-actions' is static but 'ng-tns-c139-19' can be change of any reload page.

can I locate this element without the dynamic param ?

thanks.

CodePudding user response:

yes why not.

Please use find_element_by_class_name('dataset-selection-dialog-actions')

but make sure that it is unique element in HTMLDOM.

to check if it is unique or not, use this css selector, .dataset-selection-dialog-actions

PS : Please check in the dev tools (Google chrome) if we have unique entry in HTML DOM or not.

Steps to check:

Press F12 in Chrome -> go to element section -> do a CTRL F -> then paste the css selector .dataset-selection-dialog-actions and see, if your desired element is getting highlighted with 1/1 matching node.

  • Related