5
respostas

Erro ao Rodar meu Codigo

package Caelum;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;


public class UsuariosPage {

    private WebDriver driver;


    public UsuariosPage(WebDriver driver) {
        this.driver = driver;
    }

    public void visita(){
        driver.get("localhost:8080/usuarios");
    }

    public NovoUsuarioPage novo(){
        driver.findElement(By.linkText("Novo Usuário")).click();
        return new NovoUsuarioPage(driver);
    }


    public boolean existeNaListagem(String nome, String email){
        return driver.getPageSource().contains(nome) &&
                driver.getPageSource().contains(email);
    }
}
package Caelum;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.firefox.FirefoxDriver;

import static org.junit.Assert.assertTrue;

public class UsuariosSystemTest {

    private FirefoxDriver driver;


    @Before
    public void inicializa() {
        System.setProperty("webdriver.gecko.driver", "c:\\geckodriver.exe");
        this.driver = new FirefoxDriver();
        driver.get("http://localhost:8080/usuarios");
    }

    @Test
    public void deveAdicionarUmUsuario() {

        UsuariosPage usuarios = new UsuariosPage(driver);
        usuarios.novo().cadastra("Ronaldo Luiz de Albuquerque","ronaldo2009@terra.com.br");
        assertTrue(usuarios.existeNaListagem("Ronaldo Luiz de Albuquerque","ronaldo2009@terra.com.br"));
    }

    @After
    public void finaliza() {
        driver.close();
    }
}
package Caelum;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class NovoUsuarioPage {

    private final WebDriver driver;

    public NovoUsuarioPage(WebDriver driver){
        this.driver =driver;
    }

    public void cadastra(String nome, String email){

        WebElement txtNome = driver.findElement(By.name("usuario.nome"));
        WebElement txtEmail = driver.findElement(By.name("usuario.email"));

        txtNome.sendKeys(nome);
        txtEmail.sendKeys(email);

        txtNome.submit();
    }
}
5 respostas

--- MENSAGEM DE ERRO PRIMEIRA PARTE 01---

1510670904867    geckodriver    INFO    geckodriver 0.19.1
1510670904873    geckodriver    INFO    Listening on 127.0.0.1:19058
1510670905582    mozrunner::runner    INFO    Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile" "C:\\Users\\JACKSO~1.BRA\\AppData\\Local\\Temp\\rust_mozprofile.0I0iG6mZ3qfN"
1510670905742    addons.xpi    WARN    Error parsing extensions state: [Exception... "Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [amIAddonManagerStartup.readStartupData]"  nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)"  location: "JS frame :: resource://gre/modules/addons/XPIProvider.jsm :: loadExtensionState :: line 1554"  data: no] Stack trace: loadExtensionState()@resource://gre/modules/addons/XPIProvider.jsm:1554 < getInstallState()@resource://gre/modules/addons/XPIProvider.jsm:1589 < checkForChanges()@resource://gre/modules/addons/XPIProvider.jsm:3109 < startup()@resource://gre/modules/addons/XPIProvider.jsm:2188 < callProvider()@resource://gre/modules/AddonManager.jsm:269 < _startProvider()@resource://gre/modules/AddonManager.jsm:739 < startup()@resource://gre/modules/AddonManager.jsm:906 < startup()@resource://gre/modules/AddonManager.jsm:3090 < observe()@jar:file:///C:/Program%20Files/Mozilla%20Firefox/omni.ja!/components/addonManager.js:65
1510670906353    Marionette    INFO    Enabled via --marionette
Unable to read VR Path Registry from C:\Users\jackson.brandao\AppData\Local\openvr\openvrpaths.vrpath
[Child 14964] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
1510670908271    Marionette    INFO    Listening on port 53087
1510670908701    Marionette    WARN    TLS certificate errors will be ignored for this session
1510670908764    Marionette    DEBUG    Register listener.js for window 4294967297
nov 14, 2017 10:48:28 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFORMAÇÕES: Detected dialect: W3C

--- MENSAGEM DE ERRO PRIMEIRA PARTE 02---


1510670908816    Marionette    DEBUG    Received DOM event "beforeunload" for "about:blank"
1510670908844    Marionette    DEBUG    Received DOM event "pagehide" for "about:blank"
1510670908844    Marionette    DEBUG    Received DOM event "unload" for "about:blank"
1510670909265    Marionette    DEBUG    Received DOM event "DOMContentLoaded" for "http://localhost:8080/usuarios"
1510670909521    Marionette    DEBUG    Received DOM event "pageshow" for "http://localhost:8080/usuarios"
1510670909592    Marionette    DEBUG    Received DOM event "beforeunload" for "http://localhost:8080/usuarios"
1510670909615    Marionette    DEBUG    Received DOM event "pagehide" for "http://localhost:8080/usuarios"
1510670909616    Marionette    DEBUG    Received DOM event "unload" for "http://localhost:8080/usuarios"
1510670909655    Marionette    DEBUG    Received DOM event "DOMContentLoaded" for "http://localhost:8080/usuarios/new"
1510670909703    Marionette    DEBUG    Received DOM event "pageshow" for "http://localhost:8080/usuarios/new"

--- MENSAGEM DE ERRO PRIMEIRA PARTE 03---

java.lang.AssertionError
    at org.junit.Assert.fail(Assert.java:86)
    at org.junit.Assert.assertTrue(Assert.java:41)
    at org.junit.Assert.assertTrue(Assert.java:52)
    at Caelum.UsuariosSystemTest.deveAdicionarUmUsuario(UsuariosSystemTest.java:27)
    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:498)
    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.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)


Process finished with exit code -1

Oi Jackson, tudo bem ?

Acho que você acabou duplicando a dúvida, pois o problema parece ser o mesmo aqui :(

Tem alguma sugestão para fazer funcionar o código?