我正在编写以下代码来解决硒中的陈旧元素引用。但是,在eclipse中它给我以下错误:最终布尔重试(by by)-这行。首先,我想使用public boolean retrying(By by)而不是最终布尔重试(By by),但这给出了我从日食编辑器的错误。
package com.TSOne.tcone;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class CalenderFfdriver {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver",
"/Users/owner/desktop/chromedriver");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.get("http://www.path2usa.com/travel-companions");
driver.findElement(By.cssSelector("#travel_date")).click();
List<WebElement>dates =driver.findElements(By.cssSelector(".day"));
System.out.println(dates.size());
final boolean retrying (By by) {
boolean result = false;
int attempts = 0;
while(attempts < 2) {
try {
driver.findElement(By.xpath("//*[@class='datepicker-
switch']")).click();
result = true;
break;
} catch(StaleElementReferenceException e) {
}
attempts++;
}
return;
}
WebElement navigator =driver.findElement(By.cssSelector("
[class='datepicker-days'] th[class='next']"));
while(!driver.findElement(By.cssSelector("[class='datepicker-days']
th[class='datepicker-switch']")).getText().contains("April"))
driver.findElement(By.cssSelector("[class='datepicker-days']
th[class='next']")).click();
for(int i=0;i<dates.size();i++) {
String text=dates.get(i).getText();
if(text.equalsIgnoreCase("23"))
dates.get(i).click();
}
}
}
答案 0 :(得分:0)
在cucumber.runtime.junit.UndefinedThrowable: The step "I get result one '<O'Reilly>' and result two '<result2>'" is undefined
方法之外定义final boolean retrying (By by)
方法,它应该可以工作。
main
上面的代码没有编译错误。