-3

If a part of class name is dynamic how can we handle in selenium with java?

EXP: --> the numeric part will change dynamically.

How can we identify this type of objects. Please help.

Mukesh Takhtani
  • 852
  • 5
  • 15
ARM
  • 11
  • 1
  • 2
    I'm not an expert in this area, but your question shows no effort - please show us what has been tried. Also, I would add the Java tag. Do you really need 5 Selenium tags? – bcsb1001 Dec 17 '15 at 18:42
  • Where is your HTML snippet, what have you tried so far? Please provide some code that you have tried. – Paras Dec 17 '15 at 19:01
  • Try documentation: http://www.seleniumhq.org/docs/06_test_design_considerations.jsp#location-strategies – SiKing Dec 17 '15 at 20:50

2 Answers2

1

Since you have not shared the sin-pest code which you have tried, I am taking an example of my own to give an answer to your question:

consider the below html code Buyer Attributes

In the above HTML code the class value is attr2group, that means 2 is not constant it will be changing dynamically.

so your xpath should be as below: //span[contains(@class,'attr')][contains(@class,'group')]

Hope this will help you

0

Please try to use regular expression and use "contains". During your element identification user class contains and provide the fixed sting name of the class.

ex: //*[contains(@class,'Your Fixed String name of class')]

Note: Assume that in the DON the class name is unique and no such other class has same name with a variable number attached. If so put the elements in a List and work that.

Asit Tripathy
  • 133
  • 1
  • 9