Почему я получаю NoSuchElementException в моем PageObject c selenide?

@asolntsev, подскажите пожалуйста, что делаю не так?

вот мой page:

public class PayPalFirstStepPage extends BasePage<PayPalFirstStepPage> implements Cookies, Navigation {

    @Override
    public String getUrl() {
        return null;
    }

    //private SelenideElement linkUnitedStatesCountry = $(".global-country-us").find("United States");

    private SelenideElement fieldFirstName = $("#product:fname");
    private SelenideElement fieldLastName = $("#product:lname");
    private SelenideElement fieldPhoneNumber = $("#product:phone_number");
    private SelenideElement fieldEmail = $("#product:email");
    private SelenideElement dropdownCountry = $("#product:country");
    private SelenideElement fieldAdress1 = $("#product:address_1");
    private SelenideElement fieldAdress2 = $("#product:address_2");
    private SelenideElement fieldCity = $("#product:city");

    public PayPalSecondStepPage fillOrderDetails(PurchaseData purchaseData) {

        fieldFirstName.val(purchaseData.getFirstName());
        fieldLastName.val(purchaseData.getLastName());
        fieldPhoneNumber.val(purchaseData.getPhoneNumber());
        fieldEmail.val(purchaseData.getEmail());
        dropdownCountry.selectOption(purchaseData.getCountry());
        fieldAdress1.val(purchaseData.getAddress1());
        fieldAdress2.val(purchaseData.getAddress2());
        fieldCity.val(purchaseData.getCity());

        buttonConfirm.click();

        return page(PayPalSecondStepPage.class);
    }

}

мой BaseTest, его часть:

    @BeforeSuite(alwaysRun = true)
    public void setUp() {
        addListener(new EventListener());
        //addListener(new Highlighter());
        setWebDriver(getDriver());
        VideoRecorder.conf().withVideoFolder("target/video")
                .videoEnabled(true)
                .withRecordMode(RecordingMode.ALL)
                .withVideoSaveMode(VideoSaveMode.FAILED_ONLY)
                .withFrameRate(1);
    }

    /**
     * Returns the webdriver object for that given thread
     *
     * @return - WebDriver object
     */
    public static WebDriver getDriver() {
        return WebDriverRunner.getWebDriver();
    }

в логах пишет:

09:29:12.333 [main] [INFO ] com.some-project.apps.listeners.EventListener - find element by id or name "fieldFirstName"
09:29:12.396 [main] [INFO ] com.some-project.apps.listeners.EventListener - no such element: Unable to locate element: {"method":"name","selector":"fieldFirstName"}
  (Session info: chrome=54.0.2840.98)
  (Driver info: chromedriver=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1),platform=Mac OS X 10.11.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 17 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.0.0', revision: '350cf60', time: '2016-10-13 10:48:57 -0700'
System info: host: 'Macs-Mac-mini.local', ip: '192.168.40.100', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1), userDataDir=/var/folders/1b/tp7cx1q11n31gxp3mrtmw_q00000gn/T/.org.chromium.Chromium.ua9OZQ}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=54.0.2840.98, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 6a33881f4fdbcdcbca4433bb839ae760
*** Element info: {Using=name, value=fieldFirstName}
09:29:12.506 [main] [INFO ] com.some-project.apps.listeners.EventListener - find element by id or name "fieldFirstName"
09:29:12.529 [main] [INFO ] com.some-project.apps.listeners.EventListener - no such element: Unable to locate element: {"method":"name","selector":"fieldFirstName"}
  (Session info: chrome=54.0.2840.98)
  (Driver info: chromedriver=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1),platform=Mac OS X 10.11.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 8 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.0.0', revision: '350cf60', time: '2016-10-13 10:48:57 -0700'
System info: host: 'Macs-Mac-mini.local', ip: '192.168.40.100', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1), userDataDir=/var/folders/1b/tp7cx1q11n31gxp3mrtmw_q00000gn/T/.org.chromium.Chromium.ua9OZQ}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=54.0.2840.98, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 6a33881f4fdbcdcbca4433bb839ae760
*** Element info: {Using=name, value=fieldFirstName}
09:29:17.026 [main] [INFO ] com.some-project.apps.listeners.EventListener - running script return window._selenide_jsErrors
09:29:17.034 [main] [INFO ] com.some-project.apps.listeners.EventListener - execute script return window._selenide_jsErrors
09:29:17.034 [main] [ERROR] com.some-project.apps.listeners.TestListener - FAIL com.some-project.ecommerce.OrderWithoutPromocode.purchaseStore
09:29:17.039 [main] [ERROR] com.some-project.apps.listeners.TestListener - Element not found {by id or name "fieldFirstName"}
Expected: visible
Screenshot: file:/Users/Mac/IdeaProjects/web-some-project/build/reports/tests/1481182156469.0.png
Timeout: 4 s.
Caused by: NoSuchElementException: no such element: Unable to locate element: {"method":"name","selector":"fieldFirstName"}
  at com.codeborne.selenide.impl.WebElementSource.createElementNotFoundError(WebElementSource.java:31)
  at com.codeborne.selenide.impl.ElementFinder.createElementNotFoundError(ElementFinder.java:82)
  at com.codeborne.selenide.impl.WebElementSource.checkCondition(WebElementSource.java:59)
  at com.codeborne.selenide.impl.WebElementSource.findAndAssertElementIsVisible(WebElementSource.java:72)
  at com.codeborne.selenide.commands.SetValue.execute(SetValue.java:20)
  at com.codeborne.selenide.commands.Val.execute(Val.java:17)
  at com.codeborne.selenide.commands.Commands.execute(Commands.java:139)
  at com.codeborne.selenide.impl.SelenideElementProxy.dispatchAndRetry(SelenideElementProxy.java:86)
  at com.codeborne.selenide.impl.SelenideElementProxy.invoke(SelenideElementProxy.java:62)
  at com.sun.proxy.$Proxy32.val(Unknown Source)
  at com.some-project.pages.paypal.PayPalFirstStepPage.fillOrderDetails(PayPalFirstStepPage.java:52)
  at com.some-project.ecommerce.OrderWithoutPromocode.purchaseStore(OrderWithoutPromocode.java:57)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
  at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
  at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
  at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
  at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
  at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
  at org.testng.TestRunner.privateRun(TestRunner.java:767)
  at org.testng.TestRunner.run(TestRunner.java:617)
  at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
  at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)
  at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)
  at org.testng.SuiteRunner.run(SuiteRunner.java:254)
  at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
  at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
  at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
  at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
  at org.testng.TestNG.run(TestNG.java:1057)
  at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:74)
  at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:124)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"name","selector":"fieldFirstName"}
  (Session info: chrome=54.0.2840.98)
  (Driver info: chromedriver=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1),platform=Mac OS X 10.11.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 23 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.0.0', revision: '350cf60', time: '2016-10-13 10:48:57 -0700'
System info: host: 'Macs-Mac-mini.local', ip: '192.168.40.100', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1), userDataDir=/var/folders/1b/tp7cx1q11n31gxp3mrtmw_q00000gn/T/.org.chromium.Chromium.ua9OZQ}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=54.0.2840.98, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 6a33881f4fdbcdcbca4433bb839ae760
*** Element info: {Using=name, value=fieldFirstName}
  at sun.reflect.GeneratedConstructorAccessor18.newInstance(Unknown Source)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
  at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
  at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:635)
  at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:368)
  at org.openqa.selenium.remote.RemoteWebDriver.findElementByName(RemoteWebDriver.java:449)
  at org.openqa.selenium.By$ByName.findElement(By.java:303)
  at org.openqa.selenium.support.ByIdOrName.findElement(ByIdOrName.java:50)
  at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:360)
  at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:103)
  at com.sun.proxy.$Proxy29.findElement(Unknown Source)
  at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFiringWebDriver.java:187)
  at com.codeborne.selenide.impl.WebElementSelector.findElement(WebElementSelector.java:28)
  at com.codeborne.selenide.impl.ElementFinder.getWebElement(ElementFinder.java:56)
  at com.codeborne.selenide.impl.WebElementSource.checkCondition(WebElementSource.java:44)
  ... 37 more

09:29:17.557 [main] [INFO ] com.some-project.apps.listeners.ScreenshotListener - Written screenshot to /Users/Mac/IdeaProjects/web-some-project/target/screenshots/08-12-2016_09-29-017_purchaseStore.png

Element not found {by id or name "fieldFirstName"}
Expected: visible

Screenshot: file:/Users/Mac/IdeaProjects/web-some-project/build/reports/tests/1481182156469.0.png
Timeout: 4 s.
Caused by: NoSuchElementException: no such element: Unable to locate element: {"method":"name","selector":"fieldFirstName"}
  at com.codeborne.selenide.impl.WebElementSource.createElementNotFoundError(WebElementSource.java:31)
  at com.codeborne.selenide.impl.ElementFinder.createElementNotFoundError(ElementFinder.java:82)
  at com.codeborne.selenide.impl.WebElementSource.checkCondition(WebElementSource.java:59)
  at com.codeborne.selenide.impl.WebElementSource.findAndAssertElementIsVisible(WebElementSource.java:72)
  at com.codeborne.selenide.commands.SetValue.execute(SetValue.java:20)
  at com.codeborne.selenide.commands.Val.execute(Val.java:17)
  at com.codeborne.selenide.commands.Commands.execute(Commands.java:139)
  at com.codeborne.selenide.impl.SelenideElementProxy.dispatchAndRetry(SelenideElementProxy.java:86)
  at com.codeborne.selenide.impl.SelenideElementProxy.invoke(SelenideElementProxy.java:62)
  at com.sun.proxy.$Proxy32.val(Unknown Source)
  at com.some-project.pages.paypal.PayPalFirstStepPage.fillOrderDetails(PayPalFirstStepPage.java:52)
  at com.some-project.ecommerce.OrderWithoutPromocode.purchaseStore(OrderWithoutPromocode.java:57)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
  at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
  at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
  at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
  at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
  at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
  at org.testng.TestRunner.privateRun(TestRunner.java:767)
  at org.testng.TestRunner.run(TestRunner.java:617)
  at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
  at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)
  at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)
  at org.testng.SuiteRunner.run(SuiteRunner.java:254)
  at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
  at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
  at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
  at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
  at org.testng.TestNG.run(TestNG.java:1057)
  at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:74)
  at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:124)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"name","selector":"fieldFirstName"}
  (Session info: chrome=54.0.2840.98)
  (Driver info: chromedriver=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1),platform=Mac OS X 10.11.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 23 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.0.0', revision: '350cf60', time: '2016-10-13 10:48:57 -0700'
System info: host: 'Macs-Mac-mini.local', ip: '192.168.40.100', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1), userDataDir=/var/folders/1b/tp7cx1q11n31gxp3mrtmw_q00000gn/T/.org.chromium.Chromium.ua9OZQ}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=54.0.2840.98, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 6a33881f4fdbcdcbca4433bb839ae760
*** Element info: {Using=name, value=fieldFirstName}
  at sun.reflect.GeneratedConstructorAccessor18.newInstance(Unknown Source)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
  at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
  at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:635)
  at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:368)
  at org.openqa.selenium.remote.RemoteWebDriver.findElementByName(RemoteWebDriver.java:449)
  at org.openqa.selenium.By$ByName.findElement(By.java:303)
  at org.openqa.selenium.support.ByIdOrName.findElement(ByIdOrName.java:50)
  at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:360)
  at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:103)
  at com.sun.proxy.$Proxy29.findElement(Unknown Source)
  at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFiringWebDriver.java:187)
  at com.codeborne.selenide.impl.WebElementSelector.findElement(WebElementSelector.java:28)
  at com.codeborne.selenide.impl.ElementFinder.getWebElement(ElementFinder.java:56)
  at com.codeborne.selenide.impl.WebElementSource.checkCondition(WebElementSource.java:44)
  ... 37 more

почему NoSuchElementException: no such element: Unable to locate element: {"method":"name","selector":"fieldFirstName"}?

ведь там есть драйвер, и правильно указан элемент private SelenideElement fieldFirstName = $("#product:fname");

фабрику не использую и там нет @FindBy

пробовал даже ставить this.fieldFirstName.val(purchaseData.getFirstName()); как будто именно поле находящегося в этом объекте, а не родительского класса (такого элемента в родительском - нет)

наверное суть кроется в самом элементе или может в драйвере

<selenide.version>4.0</selenide.version>
<testng.version>6.8.13</testng.version>

NoSuchElementException возникает когда у вас либо неверный локатор, либо некорректно отрабатывает ожидание и элемент не успевает подгрузиться. Попробуйте в дебагере, в Evaluate Expression, посмотреть внимательней на строку PayPalFirstStepPage.java:52

дело в том, что все сдлеано средставми Selenide, подебажу, спасибо

надо бы использовать, а не =
и фабрики никакие не нужны

хочу отказаться от FindBy :slight_smile:

1 лайк

Ну тогда надо избавиться от private SelenideElement переменных.

1 лайк

Лучше указать либо поле By, либо вообще отказаться от полей, и возвращать элемент методом
public SelenideElement myelement(){ return $(".trollolo")}

Да, я кажится понял свою ошибку… :slight_smile:

походу надо либо так делать:

  @FindBy(id = "product:fname")
  private SelenideElement fieldFirstName;

  fieldFirstName.val(purchaseData.getFirstName());

либо так:

  private By fieldFirstName = Selectors.byId("product:fname");

  $(fieldFirstName).val(purchaseData.getFirstName());

хотелось бы отказаться от этих FindBy и в методе $()

1 лайк

Ты можешь писать и так:

private SelenideElement fieldFirstName = $("#product:fname");

fieldFirstName.val(purchaseData.getFirstName());

Селенид элементы - это прокси элементы. К этому элементу будет выполняться обращение только при вызове метода манипуляции над элементом :slight_smile:

1 лайк

Так не работает, отображает в логах:

NoSuchElementException: no such element: Unable to locate element: {"method":"name","selector":"fieldFirstName"}

при дебаге:

fieldFirstName = {$Proxy32@4417} "NoSuchElementException: no such element: Unable to locate element: {"method":"name","selector":"fieldFirstName"}"
 h = {SelenideElementProxy@4453} 
  webElementSource = {ElementFinder@4454} "{by id or name "fieldFirstName"}"
   parent = {EventFiringWebDriver@4456} 
    driver = {$Proxy29@4459} "ChromeDriver: chrome on MAC (f8c0c9f18b12644b41c8df1ffd07115e)"
    eventListeners = {ArrayList@4460}  size = 1
    dispatcher = {$Proxy28@4462} "null"
   criteria = {ByIdOrName@4457} "by id or name "fieldFirstName""
    idFinder = {By$ById@4466} "By.id: fieldFirstName"
    nameFinder = {By$ByName@4467} "By.name: fieldFirstName"
    idOrName = "fieldFirstName"
   index = 0

А как ты инициализируешь объект?

в предыдущем методе у меня стоит ретерн:

    @Step("Choose subscription plan")
    public FsFirstStepPage chooseSubscriptionPlan(PurchaseData purchaseData) {

        if (purchaseData.isStatusOffer() == Constants.Status.DOUBLE_PURCHASE_OFFER) {
            chooseDoubleOfferForSubscription();
        }

        switch (purchaseData.getSubscriptionPlan()) {
            case Constants.TestData.PayPal.Price.PREMIUM_TWELVE_MONTHS:
                $(By.xpath("some xpath")).click();
                break;
        }

        return page(PayPalFirstStepPage.class);
    }

Попробуй заменить:

return page(PayPalFirstStepPage.class);

На:

return new PayPalFirstStepPage();

И в самом тесте:

open(pageUrl);
new PayPalFirstStepPage().fillOrderDetails(purchaseData);
1 лайк

неа, не канает такой варик :frowning:

я прям тест закомментировал и попытался напрямую тот объект вызвать без предыдщуего метода. Тоесть открываею страницу и делаю инициализацию объекта и в нем дергаю метод:

Selenide.open("https://page/");
new PayPalFirstStepPage().fillOrderDetails(purchaseData);

где:

private SelenideElement fieldFirstName = $("#product:fname");

fieldFirstName.val(purchaseData.getFirstName());

Интересная задачка :slight_smile:

Треш :slight_smile:

Вот так НЕ РАБОТАЕТ:

private SelenideElement fieldFirstName = $("#product:fname");

fieldFirstName.val(purchaseData.getFirstName());

а вот так РАБОТАЕТ:

private SelenideElement fieldFirstName = $(By.xpath("//*[@id=\"product:fname\"]"));

fieldFirstName.val(purchaseData.getFirstName());

толи я туплю, толи ХЗ, смотрел в документации, там айдишник вот так можно искать - $("#product:fname")

баг цсс?)) гы

ну можешь так тогда написать: $(Selectors.by("id","product:fname"));
:slight_smile: так точно уже заканает

1 лайк

тоже работкает:

private SelenideElement fieldFirstName = $(Selectors.by("id", "product:fname"));

забавная ситуация, следовательно у меня руки более мнее прямые, просто чет в Selenide не то… Может написать им куда-то, что есть такая вот ситуация?

Бывают такие тонкости, от них никуда не деться. Что-то не правильно инициализировал, что-то не правильно написал - это нормально

Вот этот локатор мог воприняться как css3 с псевдоклассом fname. Типа id элемнета это “product”, у которого есть всевдокласс “fname”. В этом всё же проблема кажется

Хмм, а ежели страница перезагрузится, обращение к этому элементу не будет падать с StaleElementException ? private SelenideElement fieldFirstName = $(Selectors.by(“id”, “product:fname”));