Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

Dúvida no Ex. 40 da Aula 4 - Testando formulários complexos

NullPointerException ao visitar a página "limpa". Como proceder?

    @Before
    public void inicializa() {
        driver.get("http://localhost:8080/apenas-teste/limpa");
        this.driver = new FirefoxDriver();        
        this.usuarios =new UsuariosPage(driver); //instanciando o objeto - esta aqui pq se repetira em quase todos os testes

    }
3 respostas

Oi Carla,

pode postar a stacktrace que você recebe ao rodar esse teste? Conseguimos te ajudar melhor com ela! :-)

org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"link text","selector":"Novo Usuário"} Command duration or timeout: 567 milliseconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52' System info: host: 'Leo', ip: '192.168.1.4', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.065' Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=43.0.4, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}] Session ID: cc68fde2-3825-41be-b800-77c6d5af1272 * Element info: {Using=link text, value=Novo Usuário} at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:353) at org.openqa.selenium.remote.RemoteWebDriver.findElementByLinkText(RemoteWebDriver.java:418) at org.openqa.selenium.By$ByLinkText.findElement(By.java:246) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:345) at UsuariosPage.novo(UsuariosPage.java:19) at TesteAutomatizado.alterandoUsuario(TesteAutomatizado.java:89) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"link text","selector":"Novo Usuário"} For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52' System info: host: 'Leo', ip: '192.168.1.4', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_65' Driver info: driver.version: unknown at .FirefoxDriver.prototype.findElementInternal(file:///C:/Users/CARLAC~1/AppData/Local/Temp/anonymous6015770297282458060webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10659) at .FirefoxDriver.prototype.findElement(file:///C:/Users/CARLAC~1/AppData/Local/Temp/anonymous6015770297282458060webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10668) at .DelayedCommand.prototype.executeInternal/h(file:///C:/Users/CARLAC~1/AppData/Local/Temp/anonymous6015770297282458060webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12534) at .DelayedCommand.prototype.executeInternal(file:///C:/Users/CARLAC~1/AppData/Local/Temp/anonymous6015770297282458060webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12539) at .DelayedCommand.prototype.execute/<(file:///C:/Users/CARLAC~1/AppData/Local/Temp/anonymous6015770297282458060webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12481)

solução!

Consegui solucionar.