Home > database >  TestCafe - How to click on "select class" when ID not available
TestCafe - How to click on "select class" when ID not available

Time:03-03

Showcase of issue

Unable to click on this dropdown list since it does not have an ID, how could I click on this select class?

CodePudding user response:

Refer to this documentation to learn how to use selectors to select elements.

Since your dropdown has an html attribute you can use Selector.withAttribute Method.

CodePudding user response:

You can use the classname, classname with the element name to locating the element.

await t.click(Selector("select.product_sort_container"));

You will have to master location strategies to locate elements in the web pages. All elements will not have IDs.

Reference :

  1. Select Page Elements
  2. Mastering CSS for web automation

Recipe : Test <Select> Elements

  • Related