Всем привет, уже не первый раз наблюдаю подобную проблему, что используя Page Object Pattern (POP) вываливается ошибка при попытке нажать на чекбокс:
70439 [main] INFO net.thucydides.core.steps.StepInterceptor - STEP FAILED: accept_terms - org.openqa.selenium.WebDriverException: unknown error: Runtime.evaluate threw exception: TypeError: Cannot read property 'click' of null
(Session info: chrome=35.0.1916.114)
(Driver info: chromedriver=2.8.240825,platform=Linux 3.8.0-35-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 295 milliseconds
Build info: version: '2.39.0', revision: '14fa800511cc5d66d426e08b0b2ab926c7ed7398', time: '2013-12-16 13:18:38'
System info: host: 'nxc003', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.8.0-35-generic', java.version: '1.8.0'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, chrome={userDataDir=/tmp/.org.chromium.Chromium.CLCF3Q}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, version=35.0.1916.114, platform=LINUX, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 54402e08961a5b03e7b489b683bcb823
70491 [main] INFO net.thucydides.core.steps.StepInterceptor - SKIPPED STEP: confirm
70493 [main] INFO net.thucydides.core.steps.StepInterceptor - SKIPPED STEP: assert_text
import net.thucydides.core.pages.PageObject;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class Summary extends PageObject
{
public WebDriver driver;
public Summary(WebDriver driver) {
super(driver);
}
@FindBy(id= "accept-terms")
private WebElement acceptTerms;
public void AcceptTerms()
{
$(acceptTerms).click();
}
}
import net.thucydides.core.annotations.Step;
import net.thucydides.core.pages.Pages;
import net.thucydides.core.steps.ScenarioSteps;
import org.junit.Assert;
import static org.hamcrest.Matchers.is;
public class MySteps extends ScenarioSteps
{
Summary summary;
public MySteps(Pages pages)
{
super(pages);
}
@Step
public void start_browser()
{
HomePage loginPage = getPages().get(HomePage.class);
loginPage.open();
}
@Step
public void accept_terms()
{
summary.AcceptTerms();
}
}
@Story(Application.Test.Booking.class)
@RunWith(ThucydidesRunner.class)
@Concurrent(threads="8")
public class BlaBlaTest
{
...........................
@WithDriver("chrome")
@WithTag("register_user")
@Test
public void RegisterUser() throws InterruptedException
{
user.start_browser();
user.homepage_select_dates_and_submit();
user.room_and_rate_page_select_room();
user.skip_extras();
user.fill_guest_info_page
(
account.getProperty("fname"),
account.getProperty("lname"),
account.getProperty("phoneNumber"),
account.getProperty("email"),
account.getProperty("address"),
account.getProperty("zipCode"),
account.getProperty("city")
);
user.submit_summaty_page(card.getProperty("cardName"), card.getProperty("cardNumber"));
user.accept_terms(); <----------------------------------------------------------------
user.confirm();
user.assert_text("Reservation Confirmed");
}
}
НО!!
если в main-классе вызвать, то всё отлично:
@WithDriver("chrome")
@WithTag("register_user")
@Test
public void RegisterUser() throws InterruptedException
{
user.start_browser();
user.homepage_select_dates_and_submit();
user.room_and_rate_page_select_room();
user.skip_extras();
user.fill_guest_info_page
(
account.getProperty("fname"),
account.getProperty("lname"),
account.getProperty("phoneNumber"),
account.getProperty("email"),
account.getProperty("address"),
account.getProperty("zipCode"),
account.getProperty("city")
);
user.submit_summaty_page(card.getProperty("cardName"), card.getProperty("cardNumber"));
AcceptTerms(); <----------------------------------------------------------------
user.confirm();
user.assert_text("Reservation Confirmed");
}
public void AcceptTerms()
{
driver.findElement(By.id("accept-terms")).click();
}
Кто-то может сталкивался? Аналогичная проблема с некоторыми селекторами(JQuery).
Можно ли всё-таки реализовать это через POP, а не захламлять main-класс?
Заранее спасибо!