【问题标题】:How To Click On Lock Image File Using Selenium Python如何使用 Selenium Python 单击锁定图像文件
【发布时间】:2021-10-19 09:16:39
【问题描述】:

我想点击附件中提供的两张图片,即来自 Studio 的文件和到 Studio 的文件以供参考。 我尝试了多种使用 JavaScript、Action 类的方法,但我无法同时点击这两个选项,即来自 Studio 的文件和到 Studio 的文件。

单击前图像被锁定,因为我们单击文件图像图标打开。 到工作室的文件也一样。

您能否帮我解决如何单击 Studio 中的文件和文件到 Studio 的方法。

控制台中存在代码的图像的 PFA。

提前致谢!!!

【问题讨论】:

    标签: python-3.x selenium selenium-webdriver browser-automation


    【解决方案1】:

    用javascript试试:

    userName = driver.find_element_by_xpath("//span[text()='Files to Studio']")
    driver.execute_script("arguments[0].click();", userName)
    

    【讨论】:

      【解决方案2】:

      你试过了吗

      //span[text()='Files to Studio']
      

      xpath ?

      喜欢:

      wait = WebDriverWait(driver, 10)
      wait.until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Files to Studio']"))).click()
      

      进口:

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

      您可以对Files from Studio 尝试相同的操作,例如//span[text()='Files from Studio']

      【讨论】:

      • 我使用了相同的逻辑,但它不起作用我在使用时遇到错误。 driver.find_element_by_xpath("//span[text()='Files to Studio']").click() {ElementClickInterceptedException}消息:元素点击被拦截:Element
      • 您是否以全屏模式启动了浏览器?
      • 感谢您的回复,但它是在 JavaScript 的帮助下工作的。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-16
      • 2020-08-10
      • 2020-02-13
      相关资源
      最近更新 更多