6

I want to select all the rows in a table that have class name either TCP_RowOdd or TCP_RowEven. Currently, I am doing it like this

oddRows = driver.find_elements_by_class_name("TCP_RowOdd")

evenRows = driver.find_elements_by_class_name("TCP_RowEven")

Is there an OR clause that can be used here to do it in a single query.

1 Answer 1

9

There are multiple ways to that, I prefer the CSS selector:

rows = driver.find_elements_by_css_selector(".TCP_RowOdd,.TCP_RowEven")

The comma in the selector means "or".


Or, we can grab all elements having a class that starts with TCP_Row:

rows = driver.find_elements_by_css_selector("[class^=TCP_Row]")
Sign up to request clarification or add additional context in comments.

1 Comment

Nice to know about the comma :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.