简体   繁体   中英

Python Selenium Click Button Inside Table

I'm trying to click on a "VIEW" button from the table shown below in the image from this site using Selenium Python.

在此处输入图像描述

I tried using xpath, name and all. How to create a loop for this?

All the entries is to be left empty just click on search button a table is displayed from there "VIEW" button is to be selected

Code:

在此处输入图像描述

Check below lines, and change the path of driver

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM