【发布时间】:2021-08-13 20:58:09
【问题描述】:
我收到 “invalid argument: 'handle' must be a string” Microsoft Edge 错误。
我认为当我添加 "w3c:false" 能力后问题会得到解决。
“w3c: false”的代码块:
if (CustomRunner.deviceThreadLocal.get().getBrowser().equals(BrowserType.EDGE)) {
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.setCapability("w3c", false);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(EdgeOptions.CAPABILITY, edgeOptions);
edgeOptions.merge(capabilities);
}
EdgeOptions.java:
package org.openqa.selenium.edge;
import static org.openqa.selenium.remote.CapabilityType.PAGE_LOAD_STRATEGY;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.MutableCapabilities;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.CapabilityType;
import java.util.Objects;
public class EdgeOptions extends MutableCapabilities {
public EdgeOptions() {
setCapability(CapabilityType.BROWSER_NAME, BrowserType.EDGE);
}
@Override
public EdgeOptions merge(Capabilities extraCapabilities) {
super.merge(extraCapabilities);
return this;
}
public void setPageLoadStrategy(String strategy) {
setCapability(PAGE_LOAD_STRATEGY, Objects.requireNonNull(strategy));
}
public EdgeOptions setProxy(Proxy proxy) {
setCapability(CapabilityType.PROXY, proxy);
return this;
}
}
但是当我想添加这个功能时,我无法运行代码,因为EdgeOptions.java中没有CAPABILITY。
我该如何解决这个问题?
【问题讨论】:
标签: java selenium microsoft-edge w3c capability