Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 用硒寻找span_Python_Selenium_Selenium Webdriver_Xpath_Webdriverwait - Fatal编程技术网

Python 用硒寻找span

Python 用硒寻找span,python,selenium,selenium-webdriver,xpath,webdriverwait,Python,Selenium,Selenium Webdriver,Xpath,Webdriverwait,我开始用Python编程,但我有一个小问题。 我想点击这部分。但是当我运行程序时,结果是出现了问题 for driver.find_elements_by_xpath(//span[@class='link-indicator'][contains(text(),'View IP Detail')]) .click() 我写了这段代码,但我的程序没有运行 有人可以帮我。要单击文本为“查看IP详细信息”的元素,可以使用以下任一选项: 使用xpath和文本上下文: 使用xpath和前面元素的

我开始用Python编程,但我有一个小问题。 我想点击这部分。但是当我运行程序时,结果是出现了问题

for driver.find_elements_by_xpath(//span[@class='link-indicator'][contains(text(),'View IP Detail')])
.click()

我写了这段代码,但我的程序没有运行


有人可以帮我。

要单击文本为“查看IP详细信息”的元素,可以使用以下任一选项:

  • 使用
    xpath
    和文本上下文:

  • 使用
    xpath
    和前面元素的textContext:

    driver.find_element_by_xpath("//span[contains(.,'ISP')]//following::span[@class='link-indicator'][contains(.,'View IP Detail')]").click()
    
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[contains(.,'ISP')]//following::span[@class='link-indicator'][contains(.,'View IP Detail')]"))).click()
    

理想情况下,要单击需要引导的元素,使
元素可单击()
,您可以使用以下任一选项:

  • 使用
    XPATH
    和文本上下文:

  • 使用
    XPATH
    和前面元素的textContext:

    driver.find_element_by_xpath("//span[contains(.,'ISP')]//following::span[@class='link-indicator'][contains(.,'View IP Detail')]").click()
    
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[contains(.,'ISP')]//following::span[@class='link-indicator'][contains(.,'View IP Detail')]"))).click()
    
  • 注意:您必须添加以下导入:

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    

但很抱歉,我不明白delated 21 in body在尝试运行代码时出现了哪些错误?@MartinGonzález delated 21 in body是代码试用部分,已从正文转换为代码片段。