从Eclipse开始使用自定义Firefox配置文件启动Selenium [英] Starting Selenium with custom Firefox profile from Eclipse
问题描述
大多数来源表明我需要启动Selenium服务器这个:
java -jar selenium-server.jar -firefoxProfileTemplate< / path / to / template />
但是,当从Eclipse中启动我的测试时,它不会使用 - 如果Selenium服务器未运行。
此线程表明我可以在DefaultSelenium构造函数中设置配置文件:
但是,由Selenium IDE(Firefox插件)为我生成的代码不使用该构造函数:
package com .example.tests;
import com.thoughtworks.selenium。*;
import java.util.regex.Pattern;
public class示例extends SeleneseTestCase {
public void setUp()throws Exception {
setUp(http://www.example.com/,* firefox) ;
}
public void testExample()throws Exception {
selenium.open(/);
selenium.click(// body);
}
}
我应该在哪里设置DefaultSelenium配置选项?还是还有其他方法可以用来加载我的自定义Firefox模板?
谢谢!
Stu
上面提供的代码版本假定您在4444端口上针对本地主机运行测试为什么它在设置中有2个参数。
要设置eclipse以运行它,您需要更新运行配置。这是在
运行>运行配置
查看有硒的项目,并添加上面的配置,以便当它运行它将接收并运行。
我个人只是启动服务器,当我开始工作,运行一个批处理文件,并在一天结束时杀死它。
I'm running Selenium tests from within Eclipse, but I can't load a custom Firefox profile.
Most sources suggest I need to launch the Selenium Server like this:
java -jar selenium-server.jar -firefoxProfileTemplate </path/to/template/>
But when launching my test from within Eclipse it doesn't use that - the tests will run if the Selenium Server isn't running.
This thread suggests that I can set the profile in the DefaultSelenium constructor:
Selenium RC - disabling browser cookie
But the code generated for me by Selenium IDE (Firefox plugin) doesn't use that constructor:
package com.example.tests;
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
public class Example extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("http://www.example.com/", "*firefox");
}
public void testExample() throws Exception {
selenium.open("/");
selenium.click("//body");
}
}
Where should I set the DefaultSelenium configuration options? Or is there some other method I can use to load my custom Firefox template?
Thanks! Stu
the version of code you have above assumes that you are running your tests against localhost on port 4444 thats why it is has 2 parameters in the setup.
To set up eclipse to run it you will need to update the run configuration. That is under
Run > Run Configurations
Have a look for the item that has selenium in it and add the config above so that when it runs it will pick it up and run.
I personally just fire up the server when I start working by running a batch file and kill it at the end of the day.
这篇关于从Eclipse开始使用自定义Firefox配置文件启动Selenium的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!