@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>