I want to click on buttons(of same name but having different href) using selenium.is it possible?
I want to click on buttons(of same name but having different href) using selenium.is it possible?
Basically i want to click on MoreInfo button from this website:
Website is:
https://www.usta.com/en/home/play/facility-listing.html?searchTerm=&distance=5000000000&address=Palo%20Alto,%20%20CA
The thing what i want is it either its possible to click MoreInfo button one by one or not? if so then please suggest my idea for it. Thanks
import time
import requests
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
import re
# ----------------------------------------------HANDLING-SELENIUM-STUFF-------------------------------------------------
driver = webdriver.Chrome()
time.sleep(5)
driver.get('https://www.usta.com/en/home/play/facility-listing.html?searchTerm=&distance=5000000000&address=Palo%20Alto,%20%20CA')
wait = WebDriverWait(driver,5)
time.sleep(10)
driver.find_element_by_xpath("//div[@class='facilityResults']/div[@class='resultsContainer clearfix']/div[@class='tableItem eventMoreInfo']/div[@class='seeMoreBtn']/a[@class='btn primaryBtn']").click()
1 Answer
1
As soon as you click on a button, all other button elements become stale as the first click would take you to a different page.
My suggestion is to extract all the href
from the page and access the url/page by sending a separate request / launching a new instance of a browser with the url and verify whatever you wanted to check.
href
If your aim is to check if the link is working / not broken, then you do not have to actually perform the click operation.
This example is in java. I assume you could figure it out.Check here for more info
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Instead of link, provide sample block of HTML. Link might get loss for future User. User need to refer HTML based on question.
– Ishita Shah
2 days ago