【发布时间】:2020-12-31 04:30:45
【问题描述】:
我需要在其第三位打开 GST Invoice 编号包含数字 2 的 2 Invoices。我修改如下:
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
driver = webdriver.Chrome(executable_path=r'D:/Chrome driver/chromedriver.exe') # Get local session(use webdriver.Chrome() for chrome)
driver.get("URL")
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//input[@id='PNRId']"))).send_keys("SHFYGW")
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='GstRetrievePageInteraction']"))).click()
toJourney=WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "table.gst-table-view")))
toJourney.find_element_by_xpath('tbody/tr/td[2]/ul[1]/li[2]/a[1]').click()
toJourney.find_element_by_xpath('tbody/tr/td[2]/ul[3]/li[2]/a[1]').click()
第一张发票正确打开,但第二张发票却给出了
ElementClickInterceptedException: element click intercepted: Element <a id="ViewInvoice" invoice-number="MP2192004AA05359" is-print="false" href="#" target="_blank" class="gst-view-print-btn ViewInvoice clsDtmPageInteraction" name="ViewInvoice">...</a> is not clickable at point (490, 559). Other element would receive the click: <a href="#" style="color: #f6e292">...</a>
(Session info: chrome=85.0.4183.102)
我在这里做错了什么?
【问题讨论】:
-
driver.execute_script("arguments[0].click();", element) 元素有问题。所以抓住元素并像这样运行它。
-
谢谢阿伦迪普。它起作用了,但为什么我们必须像这样抓取元素并执行?
-
有一个元素挡住了路。位置明智。
-
您好 arundeep,对于不同的 PNRS,发票是分散的,没有按特定顺序排列。我想打开那些 GST Invoice No 的第三位数字为 2 的发票。如何循环并获取这些发票?
标签: python html selenium automation