Как организовать явное ожидание с Page Factory?

I’m going to organize an explicit wait in Selenium like this:

WebDriverWait = new WebDriverWait(driver,30);
WebElement element = wait.until(ExpectedConditions.presenceOfElementLocated(locator));

The problem is that I don’t have the driver in my class, because I used the PageFactory, not a constructor in a test class:

MyClass myform = PageFactory.InitElements(driver, MyClass.class)

What is a good decision to organize explicit wait in this case?

Do you really need PageFactory? Would it be an option for you to replace WebElement instance variables with By locators?

1 лайк

Как оказалось достаточно создать конструктор класса принимающий на вход драйвер. Новый обьект в тестовом классе создавать не нужно. PageFactory сам передаст драйвер классу.

1 лайк