English 中文(简体)
如何等待驾驶员。
原标题:how to give wait to driver.get() explicitly in selenium using java

如何等待驾驶员,因为我们正在使用植被(URL)进行访问,因此我们非常了解。 也许需要不知的时间,那么,我们必须给他们30秒的时间,然后才能给他们分配。

以下是该守则。

package org.openqa.selenium.example;

import java.util.List;

import org.openqa.selenium.By

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver;


public class MyClass{

    public static void main(String[] args) throws Exception {

        // The Firefox driver supports javascript 

        WebDriver driver = new HtmlUnitDriver();

        // Go to the some websites

        driver.get("http://www.abced.com/123456/asd.htm");

        /***  Here we DONT get back the driver, so we need to Give Time out of 30 seconds**/

        final List<WebElement> element1= driver.findElements(By.tagName("a"));

    for (WebElement webElement : element1) {

        String urlFromPage = webElement.getAttribute("href");

                System.out.println(urlFromPage);

        }


     }

}

审判

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get(thisPage.url);

It is not working.. plz suggest, tx

问题回答

如果你要等到网页上载,你就应当使用<条码>的Loadtimeout(长时间,java.util.contimeUnit单位方法。 The implicitly Wait (long time, java.util.contant.timeUnit unit) is used to mothers for elements that haven t now but, but not mothers toload.

在您的网络驱动器上,您应采用与您使用的<代码>相类似的方法链。 这将要求:

  • manage() - the driver management interface
  • options() - the driver options interface
  • timeouts() - the timeout options interface
  • pageLoadTimeout(...) - setting the timeout to the time you want

您可找到相关的javadoc here

相反,你可以使用网络驱动器Wait,规定检查条件和最大时间。 可通过以下方式使用:

WebDriverWait _wait = new WebDriverWait(driver, new TimeSpan(0, 0, 2)); //waits 2 secs max
_wait.Until(d => d.FindElement(By.Id("name")));

我在上做了类似的回答。 问题。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签