-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
driver start stop at method level and parallel execution for web #13
base: main
Are you sure you want to change the base?
Changes from all commits
1e69b11
06d2fe0
00c2edf
d8d8240
adcad33
9a164d4
894efee
9cf2477
f655b5f
e0cb02b
8a1f545
ee65733
8d36169
7267f53
ad6cd53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.znsio.rpap.utils; | ||
|
||
import io.appium.java_client.AppiumDriver; | ||
import io.appium.java_client.service.local.AppiumDriverLocalService; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
public class DriverManager { | ||
|
||
private static ThreadLocal<WebDriver> drivers = new ThreadLocal<>(); | ||
private static ThreadLocal<AppiumDriver> appiumDrivers = new ThreadLocal<>(); | ||
private static ThreadLocal<String> tagName = new ThreadLocal<>(); | ||
|
||
public static void addDriver(WebDriver driver) { | ||
drivers.set(driver); | ||
} | ||
|
||
public static WebDriver getDriver() { | ||
return drivers.get(); | ||
} | ||
|
||
public static void addAppiumService(AppiumDriver driver) { | ||
appiumDrivers.set(driver); | ||
} | ||
|
||
public static AppiumDriver getAppiumService() { | ||
return appiumDrivers.get(); | ||
} | ||
|
||
public static void addTagNAme(String tagname) { | ||
tagName.set(tagname); | ||
} | ||
|
||
public static String getTagName() { | ||
return tagName.get(); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,67 @@ | ||
package com.znsio.rpap; | ||
|
||
import com.znsio.applitools.integration.ApplitoolsInitializer; | ||
import com.znsio.rpap.pages.Page; | ||
import com.znsio.rpap.utils.DriverFactory; | ||
import io.appium.java_client.AppiumDriver; | ||
import org.apache.log4j.Logger; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
import org.testng.ITestResult; | ||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.AfterSuite; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.BeforeSuite; | ||
import com.znsio.rpap.pages.Page; | ||
import com.znsio.rpap.utils.DriverFactory; | ||
import org.testng.xml.XmlTest; | ||
|
||
import java.io.IOException; | ||
import java.lang.reflect.Method; | ||
import java.net.MalformedURLException; | ||
|
||
import static com.znsio.reportportal.integration.utils.ReportPortalLogger.logInfoMessage; | ||
import static com.znsio.rpap.utils.DriverFactory.WEB; | ||
|
||
public class BaseTest extends ApplitoolsInitializer { | ||
protected static WebDriver driver; | ||
public class BaseTest { | ||
protected WebDriver driver; | ||
protected AppiumDriver appiumDriver; | ||
private static WebDriverWait wait; | ||
private static final Logger LOGGER = Logger.getLogger(BaseTest.class.getName()); | ||
protected Page page; | ||
protected ApplitoolsInitializer applitoolsInitializer; | ||
|
||
@BeforeSuite | ||
public void suiteSetup() throws MalformedURLException { | ||
public void suiteSetup(XmlTest suite) throws IOException { | ||
logInfoMessage("Inside @BeforeSuite of " + BaseTest.class.getSimpleName()); | ||
applitoolsInitializer = new ApplitoolsInitializer(); | ||
applitoolsInitializer.setUpApplitoolsInitializer(suite); | ||
} | ||
|
||
@BeforeMethod | ||
public void methodSetup(Method method) throws MalformedURLException { | ||
logInfoMessage("Inside @BeforeMethod of " + BaseTest.class.getSimpleName()); | ||
driver = DriverFactory.getDriver(); | ||
wait = DriverFactory.getWait(driver); | ||
logInfoMessage("Driver is ready"); | ||
page = new Page(driver, wait); | ||
logInfoMessage("Page setup is completed"); | ||
if (DriverFactory.getPlatform().equals(WEB)) { | ||
ApplitoolsInitializer.driverSetupForApplitoolsInitializer(driver); | ||
applitoolsInitializer.driverSetupForApplitoolsInitializer(driver); | ||
} else { | ||
ApplitoolsInitializer.driverSetupForApplitoolsInitializer((AppiumDriver) driver); | ||
applitoolsInitializer.driverSetupForApplitoolsInitializer((AppiumDriver) driver); | ||
} | ||
logInfoMessage("Driver is ready"); | ||
applitoolsInitializer.initiateApplitoolsInitializer(method, driver); | ||
} | ||
|
||
@BeforeMethod | ||
public void methodSetup() { | ||
page = new Page(driver, wait); | ||
logInfoMessage("Page setup is completed"); | ||
@AfterMethod | ||
public void methodTearDown(ITestResult iTestResult, Method method) { | ||
logInfoMessage("Inside @AfterMethod of " + BaseTest.class.getSimpleName()); | ||
applitoolsInitializer.closeApplitoolsInitializer(iTestResult); | ||
DriverFactory.killDriver(); | ||
} | ||
|
||
@AfterSuite | ||
public void suiteTearDown() { | ||
logInfoMessage("Killing driver"); | ||
DriverFactory.killDriver(); | ||
logInfoMessage("Inside @AfterSuite of " + BaseTest.class.getSimpleName()); | ||
applitoolsInitializer.closeBatch(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
SERVER_URL=https://eyes.applitools.com/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not change anything in applitools.properties |
||
SERVER_URL=https://jioeyes.applitools.com/ | ||
CONCURRENCY=5 | ||
MATCH_LEVEL=strict | ||
SEND_DOM=true | ||
STITCH_MODE=css | ||
TAKE_FULL_PAGE_SCREENSHOT=true | ||
VIEWPORT_SIZE=1200x700 | ||
USE_UFG=true | ||
USE_UFG=false | ||
SHOW_LOGS=false | ||
SAVE_BASELINE_FOR_NEW_TESTS=false | ||
FAIL_TEST_WHEN_DIFFERENCE_FOUND=true | ||
FAIL_TEST_WHEN_DIFFERENCE_FOUND=true | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ IS_LOCAL_DEVICE=true | |
AUTOMATION_DRIVER=uiautomator2 | ||
APP_PACKAGE_NAME=com.android2.calculator3 | ||
APP_ACTIVITY=com.android2.calculator3.Calculator | ||
APP_PACKAGE_LOCATION=https://github.com/anandbagmar/sampleAppsForNativeMobileAutomation/raw/main/AndroidCalculator.apk | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not change APP_PACKAGE_LOCATION |
||
APP_PACKAGE_LOCATION=drivers/AndroidCalculator.apk | ||
PAGE_LOAD_TIME=30 | ||
RUN_IN_CI=false | ||
BUILD_ID=BUILD_BUILDID | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
rp.endpoint=<Your ReportPortal Endpoint> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revert these changes - as these are Jio specific changes |
||
rp.uuid=<Your ReportPortal Team's UDID> | ||
rp.launch=RPAP_TEST_EXAMPLE | ||
rp.project=<Your Report Portal Project's Name> | ||
rp.endpoint=http://reportportal.jio.com | ||
rp.uuid=8a7a54c7-7bff-49bf-a40a-a8e75c7ae1ee | ||
rp.launch=qecc_TEST_EXAMPLE | ||
rp.project=qecc | ||
rp.enable=true | ||
rp.description=Automation Scenarios examples for ReportPortal & Applitools integration | ||
rp.convertimage=false | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the applitools latest PR is merged - update this version