-1

的RC启动Firefox浏览器,但它试图打开以下链接 “铬://src/content/RemoteRunner.html的sessionId = 94c0e90deec8470ab358718255d27575 &多窗口=真&的baseUrl = HTTPS%3A%2F%2Fwww.facebook.com%2F & debugMode =假& driverUrl “而不是硒RC是不开放在我的代码指定网址

”= http://localhost:4444/selenium-server/driver/https://www.facebook.com/

import static org.junit.Assert.*; 

import static org.junit.Assert.*; 

import org.junit.After; 
import org.junit.Before; 
import org.junit.Test; 

import com.thoughtworks.selenium.DefaultSelenium; 
import com.thoughtworks.selenium.Selenium; 

@SuppressWarnings("deprecation") 
public class DemoClass { 
    private Selenium selenium; 


    @Before 
    public void setUp() throws Exception { 
     selenium = new DefaultSelenium("localhost", 4444, "*firefox C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe", "https://www.facebook.com/"); 
     selenium.start(); 
    } 

    @Test 
    public void Assignment1() throws Exception { 
     selenium.open("/"); 
     assertTrue(selenium.isElementPresent("id=email")); 
     assertTrue(selenium.isElementPresent("id=pass")); 
     selenium.type("id=email", "[email protected]"); 
      selenium.type("id=pass", "[email protected]"); 
     assertEquals("[email protected]", selenium.getValue("id=email")); 
     selenium.click("id=u_0_n"); 
     selenium.waitForPageToLoad("30000"); 
    } 

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

回答

0

不要使用Selenium RC,它在很大程度上Ø utdated和不再维护。

您应该使用Selenium Webdriver,最新版本为3.1.0 for Java。如果你想运行你的Firefox测试,你还需要Geckodriver

Here is a good blog post解释了Selenium 3和Geckodriver的设置和其他基础知识。