Boa tarde, galera!
Estou fazendo um teste automatizado, exportando em java pra rodar no eclipse.
O teste roda normalmente no selenium, mas quando jogo pro eclipse mars a url da página deforma e o teste não roda direito.
tipo, a url que joguei no código é algo como isso:
www.xxxxxx.xxxxxx.com/loginX (é a versao beta do site)
Mas quando rodo no eclipse a url que vai pro navegador é:
www.xxxxxx.xxxxxx.com/loginX/loginX
O que pode estar causando o problema?
Obrigado a todos!
O Código:
import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class B002 {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
Capabilities firefoxbin = null;
driver = new FirefoxDriver(firefoxbin,null);
baseUrl = "http://stagingkaren.kiria.com/loginX";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testB002() throws Exception {
driver.get(baseUrl);
driver.findElement(By.id("email")).clear();
driver.findElement(By.id("email")).sendKeys("usuario");
driver.findElement(By.id("email")).clear();
driver.findElement(By.id("email")).sendKeys("usuario");
driver.findElement(By.id("password")).clear();
driver.findElement(By.id("password")).sendKeys("senhaparausuario");
driver.findElement(By.xpath("(//button[@type='submit'])[2]")).click();
driver.findElement(By.xpath("(//button[@type='button'])[2]")).click();
driver.findElement(By.linkText("Logout")).click();
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
private boolean isAlertPresent() {
try {
driver.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
}
private String closeAlertAndGetItsText() {
try {
Alert alert = driver.switchTo().alert();
String alertText = alert.getText();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alertText;
} finally {
acceptNextAlert = true;
}
}
}
Stack Trace:
nov 13, 2015 10:19:43 PM org.openqa.selenium.os.ProcessUtils killWinProcess
ADVERTÊNCIA: Process refused to die after 10 seconds, and couldn't taskkill it
java.lang.NullPointerException: Unable to find executable for: taskkill
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:250)
at org.openqa.selenium.os.UnixProcess.<init>(UnixProcess.java:62)
at org.openqa.selenium.os.CommandLine.<init>(CommandLine.java:38)
at org.openqa.selenium.os.WindowsUtils.killPID(WindowsUtils.java:178)
at org.openqa.selenium.os.ProcessUtils.killWinProcess(ProcessUtils.java:138)
at org.openqa.selenium.os.ProcessUtils.killProcess(ProcessUtils.java:81)
at org.openqa.selenium.os.UnixProcess$SeleniumWatchDog.destroyHarder(UnixProcess.java:247)
at org.openqa.selenium.os.UnixProcess$SeleniumWatchDog.access$2(UnixProcess.java:246)
at org.openqa.selenium.os.UnixProcess.destroy(UnixProcess.java:125)
at org.openqa.selenium.os.CommandLine.destroy(CommandLine.java:155)
at org.openqa.selenium.firefox.FirefoxBinary.quit(FirefoxBinary.java:259)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.quit(NewProfileExtensionConnection.java:204)
at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.quit(FirefoxDriver.java:364)
at org.openqa.selenium.firefox.FirefoxDriver.stopClient(FirefoxDriver.java:310)
at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:519)
at B002.tearDown(B002.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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.RunAfters.evaluate(RunAfters.java:33)
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)
driver.quit()
paradriver.close()
.close()
. mas isso não tem nada a ver com o problema da URL, certo? São 2 perguntas em 1. Tem certeza que essa URL não está definida em outro lugar? Tem certeza que não é o próprio sistema quem está redirecionando de forma errada no seu ambiente local? Não tem como o WebDriver estar simplesmente adicionando isso ali do nada.