目前,我正在使用一种工作方法,在这里我在堆栈溢出上找到的指定超时之后,杀死Selenium get线程.
String url = "https://www.myurl.me";
Integer timeout = 3000;
Thread t = new Thread(new Runnable() {
public void run() {
driver.get(Thread.currentThread().getName());
}
}, url);
t.start();
try {
t.join(timeout); // <--- Timeout specified in milliseconds
}
catch (InterruptedException e) { // ignore
}
if (t.isAlive()) { // Thread still alive, we need to abort
System.out.println("Timeout on loading page " + url);
t.interrupt();
}但是,我需要另一种方法来在指定的时间之后杀死Selenium click线程,所以如果单击链接挂起,线程就会被杀死。基本上我想杀这样的东西..。
driver.findElement(By.xpath(relXpath)).click();关于如何修改上述代码以杀死click而不是get的任何建议
发布于 2015-01-23 20:24:11
Thread t = new Thread() {
public void run() {
driver.findElement(By.xpath(elementXpath)).click();
}
};
t.setName("runThread");
t.start();
try {
t.join(3000); // <--- Timeout specified in milliseconds
}
catch (InterruptedException e) { // ignore
}
if (t.isAlive()) { // Thread still alive, we need to abort
System.out.println("Timeout on loading on xpage "+ monkeyPath);
t.interrupt();
}https://stackoverflow.com/questions/27707401
复制相似问题