page-factory

Selenium @FindBy vs driver.findElement()

我的梦境 提交于 2019-11-27 10:32:38
问题 Why should I use @FindBy vs driver.findElement() ? @FindBy forces me to move all my variables to a class level (when most of them only need to be at the method level). The only thing it seems to buy me is I can call PageFactory.initElements() , which handles lazy initialization for me. What am I missing? 回答1: Roughly speaking, @FindBy is just an alternate way of finding elements (the "usual way" being driver.findElement() as you said). The big advantage of that annotation is not itself,

How to add explicit wait in PageFactory in PageObjectModel?

被刻印的时光 ゝ 提交于 2019-11-27 09:50:44
I have added hardcode wait thread.sleep() in my below code. How to use explicit wait. I want to wait till "username" WebElement appear. My program is working perfectly. I have already written testcases. package com.pol.zoho.PageObjects; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.ui.WebDriverWait; public class ZohoLoginPage { WebDriver driver; public ZohoLoginPage(WebDriver driver) { PageFactory.initElements(driver, this); } @FindBy

NullpointerException while invoking SendKeys through Selenium using PageFactory with Page Object

大憨熊 提交于 2019-11-27 08:41:27
问题 I have three classes. One for getting all elements from the Webpage, one for performing actions with those elements and one for the test scripts. I get a null pointer exception when I call a function from the test script. I figured out this is because I use @FindBy annotation, but I don't know how to fix this. Elements Class: public class LoginPageElements { @FindBy(id="loginId") private static WebElement userNameTextBox; @FindBy(id="password") private static WebElement userPasswordTextBox;

StaleElementReference Exception in PageFactory

一曲冷凌霜 提交于 2019-11-25 21:43:09
问题 I am trying to learn the PageFactory model. I understood the fact that when we do a initElements , the WebElements are located. Say for example, I click on a webelement and because of which there is a change in one of the other webelements in DOM. Now, obviously I would get a StaleElementReferenceException here. How would I resolve this issue? Should I find that specific WebElement again knowing the fact that there can be a change in the WebElement\'s properties in the DOM? or is there an