Error while testing with selenium and JUnit!

1

What happens is that I'm doing some tests with JUnit and selenium and when doing tests I get this error message in the console:

JavaScript error: http://localhost:8080//wfi/css/jquery-confirm.css, line 10: SyntaxError: illegal character
JavaScript error: http://localhost:8080//wfi/css/jquery-confirm.less, line 11: SyntaxError: illegal character
JavaScript error: http://localhost:8080//wfi/css/jquery-confirm.css, line 10: SyntaxError: illegal character
JavaScript error: http://localhost:8080//wfi/js/jquery-confirm.js, line 12: Error: jquery-confirm requires jQuery
[Child 5896] ###!!! ABORT: Aborting on channel error.: file c:/builds/moz2_slave/m-rel-w32-00000000000000000000/build/src/ipc/glue/MessageChannel.cpp, line 2056
dic 23, 2016 11:20:13 AM org.openqa.selenium.os.UnixProcess destroy
GRAVE: Unable to kill process with PID 4764

And after a few seconds the Mozilla browser closes unexpectedly ...

This is my code that I generate when I export the test cases from Selenium IDE:

import static org.junit.Assert.fail;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public class TestModulosWFI {
  private WebDriver driver;
  private String baseUrl;
  private boolean acceptNextAlert = true;
  private StringBuffer verificationErrors = new StringBuffer();

  @Before
  public void setUp() throws Exception {
    System.setProperty("webdriver.gecko.driver", "C:\geckodriver.exe");
    driver = new FirefoxDriver();
    DesiredCapabilities cap = DesiredCapabilities.firefox();
    cap.setCapability("marionette", true);
     cap.setCapability("firefox_binary", "firefoxbinarypath");

    baseUrl = "http://localhost:8080/";
    driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
  }

  @Test
  public void testModulosWFI() throws Exception {
    driver.get(baseUrl + "/wfi/");
    driver.findElement(By.id("cveUsuario")).clear();
    driver.findElement(By.id("cveUsuario")).sendKeys("admin");
    driver.findElement(By.id("password")).clear();
    driver.findElement(By.id("password")).sendKeys("123");
    driver.findElement(By.xpath("//button[@type='submit']")).click();
    driver.findElement(By.cssSelector("button.navbar-toggle.collapsed")).click();
    driver.findElement(By.linkText("Inicio")).click();
    driver.findElement(By.cssSelector("button.navbar-toggle.collapsed")).click();
    driver.findElement(By.id("usuarios")).click();
    driver.findElement(By.linkText("Admon Proyectos")).click();
    driver.findElement(By.id("proyectos")).click();
    driver.findElement(By.cssSelector("span.caret")).click();
    driver.findElement(By.id("reportetotal")).click();
    driver.findElement(By.linkText("Admon Proyectos")).click();
    driver.findElement(By.id("detallesProyecto")).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;
    }
  }
}

I hope and you can help me! Greetings to all, for my part I will continue looking for possible solutions and if I find out right away I will publish it ...

    
asked by cratus666jose 23.12.2016 в 17:43
source

1 answer

0

Try calling the driver this way:

System.setProperty("webdriver.gecko.driver","C\geckodriver.exe");
DesiredCapabilities cap = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
driver= new FirefoxDriver(cap);
    
answered by 09.02.2017 в 23:31