简体   繁体   English

Java JUnit中的Selenium 2测试错误:无法启动新会话

[英]Selenium 2 in Java JUnit Test Error: Could not start a new session

I'm designing a website login test program in Java by using Selenium2. 我正在使用Selenium2设计一个Java的网站登录测试程序。

When I run it in JUnit in NetBeans, error shows up: "testLogin(JUnitTest.LoginTest): Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure." 当我在NetBeans中的JUnit中运行时,出现错误:“testLogin(JUnitTest.LoginTest):无法启动新会话。可能的原因是远程服务器的无效地址或浏览器启动失败。” Any idea about this? 对此有何想法? Thank you! 谢谢! Note: I have not thought of ways of testing login result, so the assertions are not going to work for now. 注意:我没有想过测试登录结果的方法,因此断言暂时不起作用。

My code: 我的代码:

public class LoginTest {

private static WebDriver driver;
private static String baseUrl;
    private static String loginUrl;

@Before
public void setUp() {
            baseUrl = "https://web.kitchology.com/kitchology/";
            loginUrl = "https://web.kitchology.com/kitchology/faces/Home.xhtml";
            System.setProperty("webdriver.chrome.driver", "E:\\Google\\Chrome\\Application\\Chrome.exe");
            driver = new ChromeDriver();
            driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

            driver.get(baseUrl);
            driver.findElement(By.id("j_idt16:sitepassword")).sendKeys("sitepass");
            driver.findElement(By.id("j_idt16:j_idt19")).click();

            driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

}

@Test
public void testLogin() throws Exception {

            driver.get(loginUrl);

            driver.findElement(By.id("j_idt16:loginLink")).click();
            driver.findElement(By.id("login")).clear();//clear any previous text
            driver.findElement(By.id("j_idt16:loginForm:username")).sendKeys("myuser");
            driver.findElement(By.id("j_idt16:loginForm:password")).sendKeys("mypass");
            driver.findElement(By.id("j_idt16:loginForm:j_idt28")).submit();
            assert("Welcome to Kitchology!" == driver.getTitle());
    assert("" == WelcomePage.getWelcomeMessage());

}

@Test
public void testFailedLogin() throws Exception {

            driver.get(loginUrl);

            driver.findElement(By.id("j_idt16:loginLink")).click();
            driver.findElement(By.id("login")).clear();//clear any previous text
            driver.findElement(By.id("j_idt16:loginForm:username")).sendKeys("myuser");
            driver.findElement(By.id("j_idt16:loginForm:password")).sendKeys("mypass");
            driver.findElement(By.id("j_idt16:loginForm:j_idt28")).submit();
    assert("" == FailedPage.getErrorMessage());

}

    @After
public void after() {
    driver.quit();
}

} }

Have you made sure that the path for 你有没有确定的路径

webdriver.chrome.driver webdriver.chrome.driver

is set up correctly? 设置正确吗?

Do you download the driver from Selenium Chrome Driver ? 你从Selenium Chrome Driver下载驱动程序吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Selenium - 无法启动 Selenium 会话:无法启动新的浏览器会话:启动浏览器时出错 - Selenium - Could not start Selenium session: Failed to start new browser session: Error while launching browser org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session error with Selenium and IE11 using Java - org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session error with Selenium and IE11 using Java org.openqa.selenium.SessionNotCreatedException:消息:无法启动新的 session。响应代码 500 错误使用 Selenium Java - org.openqa.selenium.SessionNotCreatedException: Message: Could not start a new session. Response code 500 error using Selenium Java SessionNotCreatedException: Could not start a new session. Response code 500 错误使用 Selenium Java 和 WebDriverManager 通过 pom.xml - SessionNotCreatedException: Could not start a new session. Response code 500 error using Selenium Java and WebDriverManager through pom.xml org.openqa.selenium.SessionNotCreatedException:消息:无法启动新的 session。使用 Appium Java 时出现响应代码 500 错误 - org.openqa.selenium.SessionNotCreatedException: Message: Could not start a new session. Response code 500 error using Appium Java 无法启动新的 session。 响应代码 500。消息:未知错误:DevToolsActivePort 文件不存在错误使用 Selenium ChromeDriver Java - Could not start a new session. Response code 500. Message: unknown error: DevToolsActivePort file doesn't exist error using Selenium ChromeDriver Java org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话 - org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session Selenium UnreachableBrowserException - SoapUI Groovy TestStep 中的“无法启动新会话” - Selenium UnreachableBrowserException - "Could not start a new session" in SoapUI Groovy TestStep org.openqa.selenium.SessionNotCreatedException:无法启动新的 session。 使用驱动程序 service-docker 容器创建 session 时出错 - org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Error while creating session with the driver service-docker container java.lang.RuntimeException: 无法启动 Selenium 会话: - java.lang.RuntimeException: Could not start Selenium session:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM