1
package com.memoir.client.widgets.memogen;

import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.thoughtworks.selenium.DefaultSelenium;

@SuppressWarnings("deprecation")
public class TestHomepage extends SeleneseTestCase {
    @Override
    @Before
    public void setUp() throws Exception {
        //selenium = new DefaultSelenium("localhost", 4444, "*firefox", "https://64.79.128.233/staging/");
        selenium = new DefaultSelenium("localhost", 4444, "*firefox /usr/bin/firefox", "https://64.79.128.233/staging/");
        selenium.start();
    }

    @Test
    public void testTesting4() throws Exception {
        selenium.setSpeed("2000");
        selenium.windowMaximize();
        //selenium.open("/memosyn/");
        selenium.open("/staging/");
        selenium.waitForPageToLoad("60000");
        //Checking for page layout in the beginning of the web page
        assertEquals("1", selenium.getElementIndex("//*[@id='isc_G']"));
        assertEquals("Please contact support@systems.com for questions or comments.", selenium.getText("id=contactText"));
        //assertEquals("MemoWeb V3.3.5963M", selenium.getText("//*[@id='isc_WidgetCanvas_1_widget']/div/table/tbody/tr/td[2]"));
        assertEquals("14", selenium.getElementHeight("scLocator=//VLayout[ID=\"loginBox\"]/"));
        assertEquals("447", selenium.getElementWidth("scLocator=//VLayout[ID=\"loginBox\"]/"));
        assertEquals("35", selenium.getElementHeight("scLocator=//DynamicForm[ID=\"loginItems\"]/item[name=email]/title"));
        assertEquals("207", selenium.getElementWidth("scLocator=//DynamicForm[ID=\"loginItems\"]/item[name=email]/title"));
        assertEquals("35", selenium.getElementHeight("scLocator=//DynamicForm[ID=\"loginItems\"]/item[name=password]/title"));
        assertEquals("207", selenium.getElementWidth("scLocator=//DynamicForm[ID=\"loginItems\"]/item[name=password]/title"));
        assertEquals("35", selenium.getElementHeight("scLocator=//DynamicForm[ID=\"loginItems\"]/item[name=rememberMe]/textbox"));
        assertEquals("203", selenium.getElementWidth("scLocator=//DynamicForm[ID=\"loginItems\"]/item[name=rememberMe]/textbox"));
        assertEquals("22", selenium.getElementHeight("scLocator=//Button[ID=\"submitButton\"]/"));
        assertEquals("100", selenium.getElementWidth("scLocator=//Button[ID=\"submitButton\"]/"));
        assertEquals("MemoWeb", selenium.getTitle());
        assertEquals("Email :", selenium.getText("scLocator=//DynamicForm[ID=\"loginItems\"]/item[name=email||title=Email]/title"));
        assertEquals("Password :", selenium.getText("scLocator=//DynamicForm[ID=\"loginItems\"]/item[name=password||title=Password]/title"));
        assertEquals("Remember me on this computer", selenium.getText("scLocator=//DynamicForm[ID=\"loginItems\"]/item[name=rememberMe||title=Remember%20me%20on%20this%20computer]/textbox"));
    }

    @Override
    @After
    public void tearDown() throws Exception {
        selenium.stop();
    }
}

这是代码,当我通过启动 selenium 服务器运行它时,我得到了这个错误。错误的原因可能是什么?是不是我的firefox配置文件设置不正确?

java.lang.RuntimeException: Could not start Selenium session: Failed to start new browser session: org.openqa.selenium.server.browserlaunchers.InvalidBrowserExecutableException: The specified path to the browser executable is invalid.
    at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:109)
    at com.memoir.client.widgets.memogen.TestHomepage.setUp(TestHomepage.java:16)
    at junit.framework.TestCase.runBare(TestCase.java:132)
    at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:230)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:124)
    at junit.framework.TestSuite.runTest(TestSuite.java:232)
    at junit.framework.TestSuite.run(TestSuite.java:227)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: com.thoughtworks.selenium.SeleniumException: Failed to start new browser session: org.openqa.selenium.server.browserlaunchers.InvalidBrowserExecutableException: The specified path to the browser executable is invalid.
    at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:112)
    at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:106)
    at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:275)
    at com.thoughtworks.selenium.HttpCommandProcessor.start(HttpCommandProcessor.java:237)
    at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:100)
    ... 16 more

谁能帮我解决这个问题?我收到这些错误,但我不知道请帮助我。

4

1 回答 1

0

Selenium RC 在 Eclipse 上工作,版本小于 12 。你能检查一下你使用的是哪个版本吗

于 2015-04-27T07:59:55.413 回答