You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.
What steps will reproduce the problem?
1. Declaring a WebDriverWait
What is the expected output? What do you see instead?
The test has to open the webpage and wait till the element is found.
Selenium version:2.6
OS: Windows 7
Browser: Internet Explorer
Brower version: 9
This is the code I have written
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import javax.swing.text.html.HTML;
public class sampleTest {
WebDriver driver;
// WebDriverWait wait = new WebDriverWait(driver, 120);
@BeforeTest
public void setUp() {
driver = new InternetExplorerDriver();
}
@AfterTest
public void tearDown() {
driver.quit();
}
@Test
public void TestToWait() {
driver.get("www.google.co.in");
// WebElement element = wait.until(new ExpectedCondition<WebElement>() {
// public WebElement apply(WebDriver webDriver) {
// return webDriver.findElement(By.name("q"));
// }
// });
// element.click();
}
}
The program above, works fine. When I uncomment the lines(which are commented) I get
the following error.
org.testng.TestNGException:
Cannot instantiate class com.selenium.test.sampleTest
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:37)
at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:372)
at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:284)
at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:109)
at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:184)
at org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:120)
at org.testng.TestRunner.initMethods(TestRunner.java:394)
at org.testng.TestRunner.init(TestRunner.java:228)
at org.testng.TestRunner.init(TestRunner.java:198)
at org.testng.TestRunner.<init>(TestRunner.java:154)
at org.testng.remote.RemoteTestNG$1.newTestRunner(RemoteTestNG.java:139)
at org.testng.remote.RemoteTestNG$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG.java:272)
at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:544)
at org.testng.SuiteRunner.init(SuiteRunner.java:142)
at org.testng.SuiteRunner.<init>(SuiteRunner.java:106)
at org.testng.TestNG.createSuiteRunner(TestNG.java:1116)
at org.testng.TestNG.createSuiteRunners(TestNG.java:1103)
at org.testng.TestNG.runSuitesLocally(TestNG.java:955)
at org.testng.TestNG.run(TestNG.java:900)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:28)
... 27 more
Caused by: java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:187)
at org.openqa.selenium.support.ui.FluentWait.<init>(FluentWait.java:93)
at org.openqa.selenium.support.ui.WebDriverWait.<init>(WebDriverWait.java:57)
at org.openqa.selenium.support.ui.WebDriverWait.<init>(WebDriverWait.java:36)
at com.selenium.test.sampleTest.<init>(sampleTest.java:20)
... 32 more
Process finished with exit code 0
I really cannot figure out what the problem is and what has WebDriverWait goto do with
TestNG?
Reported by amkhapare on 2011-09-17 06:41:32
The text was updated successfully, but these errors were encountered:
haha, I have some related posts in my blog, you can read them for reference.
http://ksblog.org/index.php?q=WebDriverWait-ajax-javascript-asynchronized-refresh&id=31
http://ksblog.org/index.php?q=one-useful-class-for-webdriver-a-package-class-for-webdriverwait&id=39
Originally reported on Google Code with ID 2481
Reported by
amkhapare
on 2011-09-17 06:41:32The text was updated successfully, but these errors were encountered: