IJG
IJG

Reputation: 1

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

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?

Upvotes: 0

Views: 391

Answers (2)

Alexey Filin
Alexey Filin

Reputation: 101

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.

Upvotes: 1

Janesh Kodikara
Janesh Kodikara

Reputation: 1821

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

Upvotes: 1

Related Questions