i just editied on the xpath.click option and now when i build my project there a crash at the same line where i just have updated my xpath(xpath: //span[normalize-space()='400 AED']]
) , do i need to update that link with jenkins as well , dont know what is wrong and also i am new to this CI thing ,also i am not using github its simple running as system , giving commands from cmd here is my console output kindly help
Started by user admin
Running as SYSTEM
Building in workspace C:\ProgramData\Jenkins\.jenkins\workspace\TestProject1
[TestProject1] $ cmd /c call C:\Users\WRP\AppData\Local\Temp\jenkins12274346789675918240.bat
C:\ProgramData\Jenkins\.jenkins\workspace\TestProject1>c:
C:\ProgramData\Jenkins\.jenkins\workspace\TestProject1>cd C:\Users\WRP\eclipse-workspace\PracticeProject
C:\Users\WRP\eclipse-workspace\PracticeProject>mvn clean test
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< com.NewPractice.org:PracticeProject >-----------------
[INFO] Building PracticeProject 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ PracticeProject ---
[INFO] Deleting C:\Users\WRP\eclipse-workspace\PracticeProject\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ PracticeProject ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ PracticeProject ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ PracticeProject ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ PracticeProject ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 4 source files to C:\Users\WRP\eclipse-workspace\PracticeProject\target\test-classes
[WARNING] /C:/Users/WRP/eclipse-workspace/PracticeProject/src/test/java/First_Test/Practice_Arabic.java:[64,77] unmappable character (0x8F) for encoding windows-1252
[WARNING] /C:/Users/WRP/eclipse-workspace/PracticeProject/src/test/java/First_Test/Practice_Arabic.java:[76,76] unmappable character (0x81) for encoding windows-1252
[WARNING] /C:/Users/WRP/eclipse-workspace/PracticeProject/src/test/java/First_Test/Practice_Arabic.java:[93,78] unmappable character (0x81) for encoding windows-1252
[WARNING] /C:/Users/WRP/eclipse-workspace/PracticeProject/src/test/java/First_Test/Practice_Arabic.java:[132,96] unmappable character (0x81) for encoding windows-1252
[INFO]
[INFO] --- maven-surefire-plugin:3.0.0-M7:test (default-test) @ PracticeProject ---
[INFO] Using auto detected provider org.apache.maven.surefire.testng.TestNGProvider
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Starting ChromeDriver 103.0.5060.53 (a1711811edd74ff1cf2150f36ffa3b0dae40b17f-refs/branch-heads/5060@{#853}) on port 57471
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Jul 07, 2022 11:43:01 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected upstream dialect: W3C
Jul 07, 2022 11:43:01 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found exact CDP implementation for version 103
Test was executed
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 21.677 s <<< FAILURE! - in TestSuite
[ERROR] First_Test.Task_TestNG.CheckOutTest Time elapsed: 14.925 s <<< FAILURE!
org.openqa.selenium.ElementNotInteractableException:
element not interactable
(Session info: chrome=103.0.5060.66)
Build info: version: '4.3.0', revision: 'a4995e2c09*'
System info: host: 'AWAIS-PC', ip: '192.168.1.62', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.3.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [d1dba2b10bdcd5ea06a7bd7ca089ca76, clickElement {id=c2fe92b6-a331-4fcb-a17f-8ce91b5cd10b}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 103.0.5060.66, chrome: {chromedriverVersion: 103.0.5060.53 (a1711811edd7..., userDataDir: C:\Users\WRP\AppData\Local\...}, goog:chromeOptions: {debuggerAddress: localhost:52878}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: WINDOWS, proxy: Proxy(), se:cdp: ws://localhost:52878/devtoo..., se:cdpVersion: 103.0.5060.66, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Element: [[ChromeDriver: chrome on WINDOWS (d1dba2b10bdcd5ea06a7bd7ca089ca76)] -> xpath: //span[normalize-space()='400 AED']]
Session ID: d1dba2b10bdcd5ea06a7bd7ca089ca76
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:200)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:133)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:53)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:184)
at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:569)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:257)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:78)
at First_Test.Task_TestNG.CheckOutTest(Task_TestNG.java:66)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:677)
at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:221)
at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)
at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:962)
at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:194)
at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)
at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.testng.TestRunner.privateRun(TestRunner.java:806)
at org.testng.TestRunner.run(TestRunner.java:601)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:433)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:427)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:387)
at org.testng.SuiteRunner.run(SuiteRunner.java:330)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1256)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1176)
at org.testng.TestNG.runSuites(TestNG.java:1099)
at org.testng.TestNG.run(TestNG.java:1067)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:324)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:74)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:123)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:456)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:169)
at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:595)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:581)
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] Task_TestNG.CheckOutTest:66 » ElementNotInteractable element not interactable
(Session info: chrome=103.0.5060.66)
Build info: version: '4.3.0', revision: 'a4995e2c09*'
System info: host: 'AWAIS-PC', ip: '192.168.1.62', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.3.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [d1dba2b10bdcd5ea06a7bd7ca089ca76, clickElement {id=c2fe92b6-a331-4fcb-a17f-8ce91b5cd10b}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 103.0.5060.66, chrome: {chromedriverVersion: 103.0.5060.53 (a1711811edd7..., userDataDir: C:\Users\WRP\AppData\Local\...}, goog:chromeOptions: {debuggerAddress: localhost:52878}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: WINDOWS, proxy: Proxy(), se:cdp: ws://localhost:52878/devtoo..., se:cdpVersion: 103.0.5060.66, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Element: [[ChromeDriver: chrome on WINDOWS (d1dba2b10bdcd5ea06a7bd7ca089ca76)] -> xpath: //span[normalize-space()='400 AED']]
Session ID: d1dba2b10bdcd5ea06a7bd7ca089ca76
[INFO]
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24.810 s
[INFO] Finished at: 2022-07-07T11:43:21 05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M7:test (default-test) on project PracticeProject: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Users\WRP\eclipse-workspace\PracticeProject\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
CodePudding user response:
As the element is successfully identified but raises:
org.openqa.selenium.ElementNotInteractableException
Ideally to click() on the element you need to induce WebDriverWait for the elementToBeClickable() and you can use either of the following solutions:
Using xpath and
normalize-space()
:new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.xpath("//span[normalize-space()='400 AED']"))).click();
Using xpath and
contains()
:new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.xpath("//span[contains(., '400 AED')]"))).click();