簡體   English   中英

Python Selenium 點擊表內按鈕

[英]Python Selenium Click Button Inside Table

我正在嘗試使用 Selenium Python 在此站點的圖像中單擊下表中的“查看”按鈕。

在此處輸入圖像描述

我嘗試使用 xpath,名稱和所有。 如何為此創建一個循環?

所有條目都留空只需單擊搜索按鈕從那里顯示一個表格“查看”按鈕將被選中

代碼:

在此處輸入圖像描述

檢查以下幾行,並更改驅動程序的路徑

from selenium import webdriver   
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time
opt = webdriver.ChromeOptions()
opt.add_argument("--ignore-certificate-errors")
opt.add_argument("--start-maximized")
driver = webdriver.Chrome(executable_path="C:\\chrome driver\\chromedriver.exe", options=opt)
driver.get("http://rera.rajasthan.gov.in/ProjectSearch")

search_btn = driver.find_element_by_xpath('//*[@id="btn_SearchProjectSubmit"]')
# invoke the click() action
search_btn.click()

xpath_first_view =  '//*[@id="OuterProjectGrid"]/div[3]/div[2]/div/table/tbody/tr[1]/td[7]'
# wait for the element to ensure it is available
WebDriverWait(driver,30).until(EC.element_to_be_clickable((By.XPATH,xpath_first_view)))
time.sleep(1) # to ensure click is not very quick
view1_btn = driver.find_element_by_xpath(xpath_first_view).click()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM