问题
Trying to set proxy (to OWASP ZAP Proxy port) in Cucumber via property, but to no available.
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>
I can also set it in CucumberRunner, but don't know how.
@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 {
}
Anybody know how and where to correctly set this?
Using Selenium and Webdriver I can do it like this:
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();
}
}
But how to achieve this with Cucumber? I want to use Cucumber, because Test are already written in it.
Thanks,
来源:https://stackoverflow.com/questions/35320857/selenium-and-cucumber-proxy-setting-cucumber-xml-or-cucumberrunner