कोड स्निपेट नीचे ठीक काम करता है, लेकिन मैं wait.until()
लाइन के साथ एक छोटे से समस्या हो रही है:Wait.until() के साथ सेलेनियम 2 पेजफैक्टरी इनिट एलिमेंट्स का उपयोग कैसे करें?
wait.until(new ElementPresent(By.xpath("//a[@title='Go to Google Home']")));
यह काम करता है लेकिन मैं अपने PageFactory
WebElement
homePageLink
बजाय भेजना चाहते हैं:
wait.until(new ElementPresent(homePageLink));
है ऐसा करने का कोई तरीका है?
इन नए फंसे हुए सेलेनियम 2 सुविधाओं को मेरे सिर को एक स्पिन में मिला है और मुझे अधिक दस्तावेज नहीं मिल रहा है।
धन्यवाद।
public class GoogleResultsPage extends TestBase {
@FindBy(xpath = "//a[@title='Go to Google Home']")
@CacheLookup
private WebElement homePageLink;
public GoogleResultsPage() {
wait.until(new ElementPresent(By.xpath("//a[@title='Go to Google Home']")));
assertThat(driver.getTitle(), containsString("Google Search"));
}
}
public class ElementPresent implements ExpectedCondition<WebElement> {
private final By locator;
public ElementPresent(By locator) {
this.locator = locator;
}
public WebElement apply(WebDriver driver) {
return driver.findElement(locator);
}
}
मैं SlowLoadableComponent बजाय का उपयोग करें। यह मुझे isLoaded() और load() के बीच में देरी करने देता है ताकि पेज लोड होने तक पृष्ठ फिर से प्रयास कर रहा हो। – djangofan