从Eclipse开始使用自定义Firefox配置文件启动Selenium [英] Starting Selenium with custom Firefox profile from Eclipse

查看:128
本文介绍了从Eclipse开始使用自定义Firefox配置文件启动Selenium的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Eclipse中运行Selenium测试,但是我无法加载自定义的Firefox配置文件。



大多数来源表明我需要启动Selenium服务器这个:

  java -jar selenium-server.jar -firefoxProfileTemplate< / path / to / template /> 

但是,当从Eclipse中启动我的测试时,它不会使用 - 如果Selenium服务器未运行。



此线程表明我可以在DefaultSelenium构造函数中设置配置文件:



Selenium RC - 禁用浏览器Cookie



但是,由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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆