[英]how to click on different links of directory listing in a web page using selenium web-driver python
I am scraping a website justdial where I need to click on every button ( Enquire Now ) of each profile. 我正在抓取一个网站Justdial,我需要单击每个配置文件的每个按钮( 立即查询 )。 I tried below code also but it shows ElementClickInterceptedException. 我也尝试了下面的代码,但它显示了ElementClickInterceptedException。
browser.driver.find_element_by_class_name("green-btn").first.click()
I attached the image for a reference and the source code also. 我附上了图像以供参考,并附带了源代码。
enter image description here 在此处输入图片说明
below is the inspect element code- 以下是检查元素代码-
<li class="book-btn">
<!-- <span class="dtsbtntxt">Book a Table</span> -->
<!-- <span class="inner_spr in_po"></span> -->
<!-- <a title="Book Doctor Appointment" class="bookap green-btn result_loader_3 big_dn" href="javascript:void(0);" onClick="showloader('result', 'result_loader_3', this); _ct('DBookAppointment', 'lspg', '2'); openDiv('best_deal_div', 'bestdeal', '', '9999PX744.X744.130617175155.L7U9', 5);"><i id="result_loader_3"></i>Enquire Now</a> -->
<a class="green-btn result_loader_3 wdb" onclick="_ct('gtlp', 'lspg'); showloader('result', 'result_loader_3', this); trackEvent('Get The Lowest Price', 'onclicklowestprice', 'Get The Lowest Price'); return openDiv('best_deal_div', 'bestdeal', '', '9999PX744.X744.130617175155.L7U9', 5);" href="javascript:void(0);"><i id="result_loader_3"></i>Enquire Now</a>
<span flg="2" docid="9999PX744_X744_130617175155_L7U9" countvalue="0">
Please help, how to click on each of this button using selenium web driver, I am using chrome web driver. 请帮助,如何使用Selenium Web驱动程序单击每个按钮,我正在使用chrome Web驱动程序。
To click on Enquire Now
button induce WebDriverWait
and element_to_be_clickable
() and the using following locator. 要单击Enquire Now
按钮,请诱导WebDriverWait
和element_to_be_clickable
()以及使用以下定位器。
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"//a[contains(@class,'green-btn')][contains(.,'Enquire Now')]"))).click()
You need to import followings to exeute above code. 您需要导入以下内容以执行上述代码。
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.