Home > Net >  Which locator should I use for Click Button when Id is not static?
Which locator should I use for Click Button when Id is not static?

Time:01-20

I am new at Selenium Java. Using Facebook example, I tried to write button click function using eclipse. For "Create New Account" button I tried using find element by id but it was not working because id is not static. Then I tried find element by class but an error occurred that compound class could not be used.
I have tried XPath but it is also not working. What web element can I use to locate this button?

Inspect element on Create an account button

CodePudding user response:

You can use this CSS Selector:

a[data-testid="open-registration-form-button"]

or this XPath

//a[@data-testid="open-registration-form-button"]
  •  Tags:  
  • Related