正在等待加载链接[Selenium/python]

正在等待加载链接[Selenium/python],python,selenium,selenium-webdriver,Python,Selenium,Selenium Webdriver,我正在尝试加载页面并等待特定链接,以便单击它,但我不断收到错误消息: File "flychk.py", line 82, in <module> EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, "Current")) File "/Library/Python/2.7/site-packages/selenium-2.50.1-py2.7.egg/selenium/webdriver/

我正在尝试加载页面并等待特定链接,以便单击它,但我不断收到错误消息:

      File "flychk.py", line 82, in <module>
       EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, "Current"))
      File "/Library/Python/2.7/site-packages/selenium-2.50.1-py2.7.egg/selenium/webdriver/support/wait.py", line 80, in until
      raise TimeoutException(message, screen, stacktrace)
     selenium.common.exceptions.TimeoutException: Message: 

Selenium提供了一个接口,名为
javascriptexecutor

在java中,我们正在执行以下操作:-

      if (driver.findElements("YOUR Locator").size() != 0) {  
          WebElement element= driver.findElement("YOUR Locator"));
            JavascriptExecutor executor = (JavascriptExecutor) driver;
            executor.executeScript("arguments[0].click();", element);
     }  
      else{
          System.out.println("Element not present");
      }

希望它能帮助您:)

Selenium提供了一个作为
javascriptexecutor
的接口

在java中,我们正在执行以下操作:-

      if (driver.findElements("YOUR Locator").size() != 0) {  
          WebElement element= driver.findElement("YOUR Locator"));
            JavascriptExecutor executor = (JavascriptExecutor) driver;
            executor.executeScript("arguments[0].click();", element);
     }  
      else{
          System.out.println("Element not present");
      }
希望它能帮助你:)

整理好了。 由于上一次单击而运行的模拟打开并关闭了一个新窗口,因此窗口处理是个问题。 谢谢各位

已经整理好了。 由于上一次单击而运行的模拟打开并关闭了一个新窗口,因此窗口处理是个问题。
谢谢各位

运行时间是否超过10秒?不,通常需要3-5秒。我试着给它更多的时间,但信息是一样的。我在考虑通过链接路径定位它,但每次都会发生变化,因为每次它都会生成一个唯一的链接。为什么不将元素的定位移到WebDriverWait声明之外呢?它需要10秒以上的时间吗?不,通常需要3-5秒才能运行。我试着给它更多的时间,但信息是一样的。我在考虑通过链接路径定位它,但每次都会发生变化,因为每次它都会生成一个唯一的链接。为什么不将元素的定位移到WebDriverWait声明之外呢?通过将第二个结束部分移到第二个语句,修复了错误。通过第80行中((By.PARTIAL_LINK_TEXT,“Current”)文件“/Library/Python/2.7/site packages/selenium-2.50.1-py2.7.egg/selenium/webdriver/support/wait.py”中的元素的存在仍然会出现相同的错误,直到raise TimeoutException(消息、屏幕、堆栈跟踪)selenium.common.exceptions.TimeoutException:Message:等待期间页面加载有问题。它什么也认不出来。我试过点击其他链接和标签,但它无法识别。通过将第二个结束部分移动到第二个语句来修复错误。通过第80行中((By.PARTIAL_LINK_TEXT,“Current”)文件“/Library/Python/2.7/site packages/selenium-2.50.1-py2.7.egg/selenium/webdriver/support/wait.py”中的元素的存在仍然会出现相同的错误,直到raise TimeoutException(消息、屏幕、堆栈跟踪)selenium.common.exceptions.TimeoutException:Message:等待期间页面加载有问题。它什么也认不出来。我试过点击其他链接和标签,但它无法识别。
wait = WebDriverWait(browser, 10)
)

wait.until(
    EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, "Current"))

currentresults = driver.find_element_by_partial_link_text("Current")

currentResults.click()
      if (driver.findElements("YOUR Locator").size() != 0) {  
          WebElement element= driver.findElement("YOUR Locator"));
            JavascriptExecutor executor = (JavascriptExecutor) driver;
            executor.executeScript("arguments[0].click();", element);
     }  
      else{
          System.out.println("Element not present");
      }