Reputation: 761
Can someone please advise how I can tell Selenium to keep clicking on the "Next Page" button until it finds specific month? I can use it to get to a specific page, where I can find this title id, but I can't figure out how to tell if I'm on "December 2017" page? And if not, click the "Next" button again. You can see in the line below that I'm on November 2017 page:
<td id="ctl00_cphBody_rcTitle" class="rcTitle">November 2017</td>
Here is my Python code up to a point where I'm stuck...
next_page_button = browser.find_element_by_id("ctl00_cphBody_rdc_NN")
# This click takes me to a calendar page
next_page_button.click()
# Now I'm on a calendar page, I have the class name, but how to tell for what month???
my_month = browser.find_element_by_class_name("rcTitle")
Can someone please advise? Thank you!
Upvotes: 0
Views: 75
Reputation: 950
The .text
method will return the text value of the element. I would also use the id instead of the class as locators (unless the id is duplicated somewhere else on the page).
my_month = browser.find_element_by_class_name("rcTitle").text
Upvotes: 2