Eclipse is corrupting url in automated testing

Asked

Viewed 128 times

3

Good afternoon, you 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 Rs the page url deforms and the test does not run correctly.

like, the url I played in the code is something like this:

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

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

www.xxxxxx.xxxxxx.com/loginX/loginX

What could 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)
  • Po, sorry to take your time & #Xa;and thanks for the help but where’s the bug? I have some 40 test cases giving error and I have to fix them. I’m recording in Lenium and exporting pro eclipse. i refer the libraries jar and rotate the case as junit. do not know where to err

  • I’m sorry it took me so long to respond, but yesterday I was on my cell phone and I was hoping someone else would do it before me. I’m not sure of the answer, but try to change where it is driver.quit() for driver.close().

  • Fabio. welcome to [en.so]! @Math is right, probably the exception will disappear if you use close(). but this has nothing to do with the URL problem, right? It’s 2 questions in 1. Are you sure this URL isn’t set elsewhere? Are you sure it is not the system itself that is redirecting in the wrong way in your local environment? There’s no way that Webdriver is just adding that out of thin air.

1 answer

0

driver = new FirefoxDriver(firefoxbin,null);

Try changing to something like:

WebDriver driver = new FirefoxDriver();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.