Selenium和Cucumber代理设置(cucumber.xml或CucumberRunner)

时间:2016-02-10 16:36:32

标签: selenium cucumber zap

尝试通过属性在Cucumber中设置代理(到OWASP ZAP代理端口),但是没有可用。

cucumber.xml

  <beans profile="firefoxRemote">
        <bean name="capability" init-method="firefox"
              class="org.openqa.selenium.remote.DesiredCapabilities">
            <property name="browserName" value="firefox"/>
            <property name="version" value="42.0"/>
            <property name="PROXY" value="127.0.0.1:8090"/>
        </bean>

我也可以在CucumberRunner中设置它,但不知道如何。

@RunWith(Cucumber.class)
@CucumberOptions(
        features = {"src/test/java/com/features"},
        glue = "com.mycompany.steps",
        format = {"pretty", "html:target/cucumber", "json:target/cucumber.json"},
        tags = {"~@ignore"})
public class CucumberRunner {
}

有人知道如何以及在何处正确设置此内容?

使用Selenium和Webdriver我可以这样做:

public class ZAPRunner {

    private WebDriver driver;
    private String site = "http://localhost:8080/app";

    public void setUp() throws Exception {
        Proxy proxy = new Proxy();
        proxy.setHttpProxy("localhost:8090");
        proxy.setFtpProxy("localhost:8090");
        proxy.setSslProxy("localhost:8090");
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.PROXY, proxy);
        driver = new FirefoxDriver(capabilities);
        this.setDriver(driver);
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    }
    protected void setDriver(WebDriver driver) {
        this.driver = driver;
    }


    public static void main(String[] args) throws Exception {
        ZAPRunner test = new ZAPRunner();
        test.setUp();

    }

}

但如何用Cucumber实现这一目标?我想使用Cucumber,因为Test已经写好了。

谢谢,

0 个答案:

没有答案