Eclipse is corrupting url in automated testing

3

Good afternoon, guys!

I'm doing an automated test, exporting in java to run in eclipse.

The test runs normally in selenium, but when I play pro eclipse mars the page url deforms and the test does not spin right.

Type, the url I played in the code looks something like this:

www.xxxxxx.xxxxxx.com/loginX ( is the beta version of the site )

But when I run in eclipse the url that goes to the browser is:

www.xxxxxx.xxxxxx.com/loginX/loginX

What might be causing the problem?

Thank you all!

The Code:

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)
    
asked by anonymous 12.11.2015 / 17:35

1 answer

0

driver = new FirefoxDriver(firefoxbin,null);

Try changing to something like:

WebDriver driver = new FirefoxDriver();

    
20.06.2016 / 04:00