Scorpisces
Scorpisces

Reputation: 79

Check background of item in table web using Selenium with Python

pic 1 table

pic 2

htmlcode

I have a table as pic 1. I need to find one invalid cell (valid: green-background, invalid: red-background). If they're all valid as picture, I must press to back previous page I got script to get current page:

current_page =driver.find_element("//span[@class='currentPage']).get_attribute("innerText")

But I don't know how to loop through each cell of table to find which one valid or not to click or do other actions.

Thank your help in advance

Upvotes: 0

Views: 53

Answers (1)

Timeler
Timeler

Reputation: 387

you can get all elements with a certain class/css selector/whatever by using driver.find_elements_by_whatever_you_want . then you can loop through the elements by using a simple for i in elements loop and get the attribute for every element. you can then say what happens if the cell is valid or not.

Upvotes: 1

Related Questions