nerak99
nerak99

Reputation: 660

Selenium state of button to be clicked

I have a site which is populated from a database. I want to access the pages in Selenium. The number pages associated with a particular topic is variable.

Using Selenium I am clicking through successive pages using a line like

driver.find_element_by_xpath("""//*[@id="mainContent"]/
                                     div[2]/div/div[2]/div[1]/
                                     div[3]/div[2]""").click()

This works successfully.

However I would like to detect when the element I am clicking (a next button) is "greyed" out rather than having to predict how many pages are available.

Currently I am using a block of code inside a for loop with a counter for the number of available pages.

EDIT: The page element has the word Inactive added when it is "greyed out" as in

<div class="paginationBtn paginationNextContainer inactive"><div class="icn chevron-left"></div><div class="visuallyHidden">Previous</div></div>

Upvotes: 1

Views: 59

Answers (1)

AutomatedOwl
AutomatedOwl

Reputation: 1089

If your button is changing its color on click, it's associated with CSS attribute.

I advise to look at this answer to learn the subject. For your case, I advise you to develop a method to get the button color value before and after, as your script should operate accordingly.

Upvotes: 1

Related Questions