Skip to content

Commit

Permalink
fix chrome driver dependency and run code with latest dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
kalpeshchilka committed Feb 3, 2022
1 parent 5a48e95 commit 04bb9ce
Show file tree
Hide file tree
Showing 15 changed files with 651 additions and 94 deletions.
40 changes: 38 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
<version>4.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
Expand All @@ -96,7 +96,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
<version>2.11.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.vimalselvam/cucumber-extentsreport -->
<dependency>
Expand All @@ -114,5 +114,41 @@
<artifactId>extentreports</artifactId>
<version>3.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>4.1.2</version>
<exclusions>
<exclusion>
<groupId>com.google.common</groupId>
<artifactId>google-collect</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.0.3</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>23.0</version>
<exclusions>
<exclusion>
<groupId>com.google.common</groupId>
<artifactId>google-collect</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
</dependency>

</dependencies>
</project>
11 changes: 7 additions & 4 deletions src/main/java/com/dkatalislabs/testbase/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Properties;
import java.util.concurrent.TimeUnit;

import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
Expand Down Expand Up @@ -34,12 +35,14 @@ public class BaseTest {
@BeforeMethod
public static WebDriver initialization(String browserName) {
if (browserName.equalsIgnoreCase("chrome")) {
String exePath = System.getProperty("user.dir") + "//lib//chromedriver";
System.setProperty("webdriver.chrome.driver", exePath);
WebDriverManager.chromedriver().setup();
// String exePath = System.getProperty("user.dir") + "/lib/chromedriver";
// System.setProperty("webdriver.chrome.driver", exePath);
driver = new ChromeDriver();
} else if (browserName.equalsIgnoreCase("firefox")) {
String exePath = System.getProperty("user.dir") + "//lib//geckodriver";
System.setProperty("webdriver.gecko.driver", exePath);
WebDriverManager.firefoxdriver().setup();
// String exePath = System.getProperty("user.dir") + "/lib/geckodriver";
// System.setProperty("webdriver.gecko.driver", exePath);
driver = new FirefoxDriver();
}

Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/dkatalislabs/utilities/ActionMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void waitForElementPresent(String locator, ELEMENT_LOCATE_BY ele, int wai
WebDriverWait wait = new WebDriverWait(driver, waitTime);
switch (ele) {
case XPATH:
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(locator)));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(locator)));
break;

case ID:
Expand All @@ -88,15 +88,15 @@ public void waitForElementPresent(String locator, ELEMENT_LOCATE_BY ele, int wai

}

public void waitForPageLoad() {
(new WebDriverWait(driver, 5)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver driver) {
JavascriptExecutor js = (JavascriptExecutor) driver;
String readyState = js.executeScript("return document.readyState").toString();
return (Boolean) readyState.equals("complete");
}
});
}
// public void waitForPageLoad() {
// (new WebDriverWait(driver, 5)).until(new ExpectedCondition<Boolean>() {
// public Boolean apply(WebDriver driver) {
// JavascriptExecutor js = (JavascriptExecutor) driver;
// String readyState = js.executeScript("return document.readyState").toString();
// return (Boolean) readyState.equals("complete");
// }
// });
// }

public WebElement waitForClickabilityOfElement(String locator, int timeOutPeriod) {
WebDriverWait webDriverWait = new WebDriverWait(driver, timeOutPeriod);
Expand Down
154 changes: 154 additions & 0 deletions target/executionReport/cucumber-pretty.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,110 @@ Feature: Test and verify End to End Checkout flow
@SmokeTest
Scenario Outline: Verify user is successfully able to purchase Pillow using correct Credit Card payment details # features/BuyProduct.feature:13
Given User is on the homepage # BuyProductStepDefinations.user_is_on_the_homepage()
java.lang.ExceptionInInitializerError
at cucumber.deps.com.thoughtworks.xstream.XStream.setupConverters(XStream.java:820)
at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:574)
at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:530)
at cucumber.runtime.xstream.LocalizedXStreams$LocalizedXStream.<init>(LocalizedXStreams.java:50)
at cucumber.runtime.xstream.LocalizedXStreams.newXStream(LocalizedXStreams.java:37)
at cucumber.runtime.xstream.LocalizedXStreams.get(LocalizedXStreams.java:29)
at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
at cucumber.runtime.Runtime.runStep(Runtime.java:300)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
at cucumber.runtime.model.CucumberScenarioOutline.run(CucumberScenarioOutline.java:46)
at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165)
at cucumber.api.testng.TestNGCucumberRunner.runCucumber(TestNGCucumberRunner.java:63)
at com.dkatalislabs.TestRunner.TestRunner.feature(TestRunner.java:50)
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.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:132)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:599)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:174)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:822)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:147)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.testng.TestRunner.privateRun(TestRunner.java:764)
at org.testng.TestRunner.run(TestRunner.java:585)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
at org.testng.SuiteRunner.run(SuiteRunner.java:286)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1218)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.runSuites(TestNG.java:1069)
at org.testng.TestNG.run(TestNG.java:1037)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:283)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:120)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:377)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:138)
at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:465)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:451)
at ✽.Given User is on the homepage(features/BuyProduct.feature:6)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module @2f3d6cd8
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
at cucumber.deps.com.thoughtworks.xstream.core.util.Fields.locate(Fields.java:39)
at cucumber.deps.com.thoughtworks.xstream.converters.collections.TreeMapConverter.<clinit>(TreeMapConverter.java:50)
at cucumber.deps.com.thoughtworks.xstream.XStream.setupConverters(XStream.java:820)
at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:574)
at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:530)
at cucumber.runtime.xstream.LocalizedXStreams$LocalizedXStream.<init>(LocalizedXStreams.java:50)
at cucumber.runtime.xstream.LocalizedXStreams.newXStream(LocalizedXStreams.java:37)
at cucumber.runtime.xstream.LocalizedXStreams.get(LocalizedXStreams.java:29)
at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
at cucumber.runtime.Runtime.runStep(Runtime.java:300)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
at cucumber.runtime.model.CucumberScenarioOutline.run(CucumberScenarioOutline.java:46)
at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165)
at cucumber.api.testng.TestNGCucumberRunner.runCucumber(TestNGCucumberRunner.java:63)
at com.dkatalislabs.TestRunner.TestRunner.feature(TestRunner.java:50)
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.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:132)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:599)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:174)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:822)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:147)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.testng.TestRunner.privateRun(TestRunner.java:764)
at org.testng.TestRunner.run(TestRunner.java:585)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
at org.testng.SuiteRunner.run(SuiteRunner.java:286)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1218)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.runSuites(TestNG.java:1069)
at org.testng.TestNG.run(TestNG.java:1037)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:283)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:120)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:377)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:138)
at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:465)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:451)

When User proceeds for Checkout with Credit Card Payment # BuyProductStepDefinations.user_proceeds_for_checkout()
And Enters Credit Card payment details with CardNumber as 4811 1111 1111 1114 , ExpriyDate as 12/24 , CVVNumber as 123 and BanksOTP as 112233 # BuyProductStepDefinations.enters_valid_credit_card_payment_details_as_and_and_and(String,String,String,String)
Then Verify payment is successfully completed # BuyProductStepDefinations.verify_payment_is_successfully_completed()
Expand All @@ -29,6 +133,56 @@ Feature: Test and verify End to End Checkout flow
@SmokeTest
Scenario Outline: Verify user is unable to purchase Pillow using incorrect Credit Card payment details # features/BuyProduct.feature:25
Given User is on the homepage # BuyProductStepDefinations.user_is_on_the_homepage()
java.lang.NoClassDefFoundError: Could not initialize class cucumber.deps.com.thoughtworks.xstream.converters.collections.TreeMapConverter
at cucumber.deps.com.thoughtworks.xstream.XStream.setupConverters(XStream.java:820)
at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:574)
at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:530)
at cucumber.runtime.xstream.LocalizedXStreams$LocalizedXStream.<init>(LocalizedXStreams.java:50)
at cucumber.runtime.xstream.LocalizedXStreams.newXStream(LocalizedXStreams.java:37)
at cucumber.runtime.xstream.LocalizedXStreams.get(LocalizedXStreams.java:29)
at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
at cucumber.runtime.Runtime.runStep(Runtime.java:300)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
at cucumber.runtime.model.CucumberScenarioOutline.run(CucumberScenarioOutline.java:46)
at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165)
at cucumber.api.testng.TestNGCucumberRunner.runCucumber(TestNGCucumberRunner.java:63)
at com.dkatalislabs.TestRunner.TestRunner.feature(TestRunner.java:50)
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.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:132)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:599)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:174)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:822)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:147)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.testng.TestRunner.privateRun(TestRunner.java:764)
at org.testng.TestRunner.run(TestRunner.java:585)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
at org.testng.SuiteRunner.run(SuiteRunner.java:286)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1218)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.runSuites(TestNG.java:1069)
at org.testng.TestNG.run(TestNG.java:1037)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:283)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:120)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:377)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:138)
at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:465)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:451)
at ✽.Given User is on the homepage(features/BuyProduct.feature:18)

When User proceeds for Checkout with Credit Card Payment # BuyProductStepDefinations.user_proceeds_for_checkout()
And Enters Credit Card payment details with CardNumber as 4911 1111 1111 1113 , ExpriyDate as 02/21 , CVVNumber as 123 and BanksOTP as 112233 # BuyProductStepDefinations.enters_valid_credit_card_payment_details_as_and_and_and(String,String,String,String)
Then Verify payment is Failed # BuyProductStepDefinations.verify_payment_is_failed()
Loading

0 comments on commit 04bb9ce

Please sign in to comment.