Issue
I am using Selenium via Python in attempts to web scrape. I'm almost where I want to be but I ran into what I am now realizing is not so small of a problem. So the element I am working with is this:
<td class=" ui-datepicker-days-cell-over ui-datepicker-current-day ui-datepicker-today"
data-handler="selectDay" data-event="click" data-month="3" data-year="2018">
<a class="ui-state-default ui-state-highlight ui-state-active" href="#">10
</a>
</td>
My ultimate goal is to get the 10 that's between the a tags. This is my code so far:
option = selenium.webdriver.ChromeOptions()
option.add_argument(" - incognito")
browser = webdriver.Chrome(executable_path=r"chromedriver.exe")
browser.get(myUrl)
calendar = browser.find_element_by_xpath(
'/html/body/main/section/div[2]/div[1]/div[2]/div[3]/div/div[1]/div/div[1]/div[2]')
viewCal = browser.find_element_by_name('choice_set[begin_at]')
viewCal.click()
row = calendar.find_elements_by_tag_name('tr')
column = calendar.find_elements_by_tag_name('td')
numb = column[0].find_element_by_tag_name('a')
numb.text
numb.text
returns ''
instead of 10.
What am I doing wrong here?
Solution
Try to use the following code:
numb.get_attribute("innerText")
Answered By - Ratmir Asanov
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.