2011-03-30 94 views
6

我试图通过将自定义的Firefox配置文件传递给DefaultSelenium构造函数启动硒服务器。它使用指定的URL打开浏览器。Selenium服务器不启动自定义Firefox的配置文件

DefaultSelenium selenium = new DefaultSelenium("localhost", 4444, "*custom \"C:/Program Files/Mozilla Firefox/firefox.exe\"",ReadConFile.readcoFile("serverName")); 
    selenium.start(); 

日志是

16:39:19.246 INFO - Allocated session 4eb63d37a4ba4d2fb4e351f8f59e3ea6 for https://<myURL>, launching... 

那么它保持这样的,服务器无法启动。

但是,如果我不使用自定义配置文件,这工作正常。

DefaultSelenium selenium = new DefaultSelenium("localhost", 4444, "*chrome",ReadConFile.readcoFile("serverName")); 
selenium.start(); 

我需要启动自定义配置文件,因为我保存了https所需的一些站点证书。另外,我从eclipse执行这个。

我想我的服务器没有配置为启动自定义配置文件。请帮我解决一下这个。

+0

您还可以在java中启动Selenium服务器。见[这里] [1]。 [1]:http://stackoverflow.com/questions/2341109/starting-selenium-with-custom-firefox-profile-from-eclipse/4600601#4600601 – 2011-11-16 04:48:31

回答

6

start命令是不是真的开始您的硒服务器本身,它是你的硒对象连接到已经运行的服务器与您所选择的浏览器。

实际开始发送/经由指定浏览器中被测接收命令以应用程序中的硒[码头的Web]服务器,使用批处理文件和开关rs79被参照。您的批处理文件的内容应包括他行:

java -jar selenium-server-standalone-2.0a5.jar -firefoxProfileTemplate C:\custom-firefox-profile 

现在你有一个真正的硒服务器的dev的机器(本地主机)使用默认的“4444”端口上运行。这将指定任何Firefox浏览器测试将使用此配置文件。

现在你DefaultSelenium构造函数,赋值,以及其他电话可以是这样的:

DefaultSelenium selenium = new DefaultSelenium("localhost", 4444, "*firefox","http://www.server.com"); 
selenium.start() 
selenium.open("myApp/") 

Firefox将开始使用启动Selenium服务器,你需要的基本URL在批处理文件中指定的自定义配置文件,然后导航到您想要的应用程序[URL]。如果从“http://www.server.com/”开始测试而不是“http://www.server.com/myApp”,则可以省略最后的打开一行。

+0

对于当前的硒实施检查http://stackoverflow.com/a/28983844/1266040 – abrasadera 2015-03-11 10:17:42

1

当您调用Selenium RC服务器时,使用其他-firefoxProfileTemplate子句指定路径。 例如 -

java -jar selenium-server-standalone-2.0a5.jar -firefoxProfileTemplate C:\custom-firefox-profile 

这将使您能够使用已保存的自定义配置文件中的所有绑定。

+0

我开始使用eclipse服务器。我怎样才能配置它开始使用-firefoxProfileTemplate。 – 9ikhan 2011-03-30 15:21:40

0

您也可以在java中启动Selenium服务器,请参阅here

1
  1. 如果你想有Fifefox配置文件作为默认在您的测试:
    一)下载最新selenium-serverhttp://selenium-release.storage.googleapis.com/index.html
    B)下载最新Firefox
    C)创建FF型材(最好在你的自定义目录中) - 在我的情况下命名为“atf”https://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles
    默认目录wh ERE配置文件保存:

    C:\Users\johndoe\AppData\Roaming\Mozilla\Firefox\Profiles 
    

    d)在我来说,我使用FF 36selenium-server-standalone-2.45.0.jar
    运行selenium server

    java -jar C:\driver\selenium-server-standalone-2.45.0.jar -Dwebdriver.firefox.profile=atf 
    

    然后参考它在你的代码:

    driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub',  
             desired_capabilities=DesiredCapabilities.FIREFOX) 
    
  2. 如果你想提及特定的教授ILE在你的代码(这里我用默认生成的文件夹命名为“我的资料”的个人资料):

    profile_path = C:/Users/johndoe/AppData/Roaming/Mozilla/Firefox/Profiles/2zvl3dxx.myProfile" 
    fp = webdriver.FirefoxProfile(profile_path) 
    driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', 
             desired_capabilities=DesiredCapabilities.FIREFOX, 
             browser_profile=myProfile) 
    
  3. 您可以将证书添加到自定义配置文件
    一)运行浏览器,自定义配置文件
    B)添加证书
    C)记得在Firefox首选项打勾选项/高级/证书
    Select one automatically
    ,以避免要求接受证书,每一个在您访问测试页面时
    d)重新启动浏览器
    E)导航到页面什么都会进行测试,并接受User Identification Request
    F)关闭Firefox和享受自定义配置文件从硒服务器提供证书:)

相关问题