Reputation: 33
I need to parse prices from
I want to take the maximum possible period. But when I use
driver.find_elements(By.CLASS_NAME, 'btn-group')[-1].click(
)
I get 15 years.
How I can fix it?
Can I additionally upload all these elements to the list and select the last one from them?
Upvotes: 0
Views: 1328
Reputation: 16187
Try to click on last element using xpath expression
driver.find_elements(By.XPATH, '//*[@class="btn-group"]//a')[-1].click()
Upvotes: 2
Reputation: 33361
Looks like you need to put some delay before the
driver.find_elements(By.CLASS_NAME, 'btn-group')
command.
It seems that you are grabbing the elements before all of them are loaded properly.
So, I think
time.sleep(2)
driver.find_elements(By.CLASS_NAME, 'btn-group')[-1].click()
should work better
Upvotes: 1