Skip to content

Commit

Permalink
added parallel-support
Browse files Browse the repository at this point in the history
  • Loading branch information
deepaktiwari committed Dec 18, 2024
1 parent e274ded commit db6f6d2
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,52 @@ public boolean waitForElementVisible(WebElement element, long timeOutInSeconds,
return element.isDisplayed();
}

public boolean waitForElementToBeClickable(WebElement element, long timeOutInSeconds, AppUiObjectNames elementNameForLogging) {

try {

if (element == null) {
return false;
}
elementNameForLogging = getElementName(elementNameForLogging);

WebDriverWait wait = new WebDriverWait(this.driver, Duration.ofSeconds(timeOutInSeconds));
testCase.info("Waiting for the element " + elementNameForLogging + " about " + timeOutInSeconds + " seconds..");

wait.until(ExpectedConditions.elementToBeClickable(element));
} catch (Exception e) {
// testCase.error(e);
logger.severe("Not Found . ");
return false;
}
testCase.info(elementNameForLogging + " Found ");
return element.isDisplayed();
}

public void waitAndClick(WebElement element, long timeOutInSeconds, AppUiObjectNames elementNameForLogging) {

try {

if (element == null) {
logger.severe("Element is null. So Returning..");
testCase.fail("Element is null. So Returning..");
return;
}
elementNameForLogging = getElementName(elementNameForLogging);

WebDriverWait wait = new WebDriverWait(this.driver, Duration.ofSeconds(timeOutInSeconds));
testCase.info("Waiting for the element " + elementNameForLogging + " about " + timeOutInSeconds + " seconds..");
wait.until(ExpectedConditions.elementToBeClickable(element));
element.click();
} catch (Exception e) {
testCase.fail(e);
logger.severe("Element Not Found");testCase.fail("Element Not found.");


}
}



public boolean waitForElementInvisible(WebElement element, long timeOutInSeconds, AppUiObjectNames elementNameForLogging) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public WebDriver createDriverForBrowser(String browserName) throws MalformedURLE
options.addArguments("--headless");
}
driver=executionMode.equalsIgnoreCase("cloud")?new ChromeDriver(options):new ChromeDriver();
System.out.println();

// driver=new ChromeDriver(options);
break;
case "safari":
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#automation Platform can be android or ios,web,api
AutomationPlatform=android
AutomationPlatform=web
UiEnv=staging
ApiEnv=staging
#execution mode can be local or cloud
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.MediaEntityBuilder;
import com.aventstack.extentreports.Status;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.ct.framework.aut.pojo.User;
import com.ct.framework.aut.screens.BaseScreen;
import com.ct.framework.aut.screens.WelcomeScreen;
Expand All @@ -17,6 +15,8 @@
import com.ct.framework.contracts.adapters.MobileDriverActionAdapter;
import com.ct.framework.prerequisite.ConfigurationModule;
import com.ct.framework.prerequisite.PlatformDriverManager;
import com.google.inject.Inject;
import com.google.inject.Injector;
import org.openqa.selenium.WebDriver;
import org.testng.ITestResult;
import org.testng.annotations.*;
Expand Down Expand Up @@ -81,7 +81,7 @@ public class TS_CT_UI_BaseTest {
@BeforeSuite()
public void setUp() throws Exception {

// baseScreen.driver=driver;
// baseScreen.driver=driver;
//add file handler to the logger.
logger.info("Before Suite..");
currentTestCase = extent.createTest("Before Suite");
Expand All @@ -105,7 +105,7 @@ public void finishTest() {
@BeforeClass
public void setScreens() {

currentTestCase = extent.createTest("Before Class");
currentTestCase = extent.createTest("Before Class");
// smcCoreUiCommons.setLoginScreen(loginScreen);
// smcCoreUiCommons.setWelcomeScreen(welcomeScreen);
// smcCoreUiCommons.setHomeScreen(homeScreen);
Expand Down Expand Up @@ -145,14 +145,14 @@ public void afterEachTestCase(ITestResult result, XmlTest test) {
break;
case 2:
//String screenshotPath = commonUtil.getScreenShot(driver, result.getName());
String base64StringFail= commonUtil.getImageAsBase64(driver,result.getName());
String base64StringFail = commonUtil.getImageAsBase64(driver, result.getName());
currentTestCase.log(Status.FAIL, "TEST FAILED.REFER SCREENSHOT", MediaEntityBuilder.createScreenCaptureFromBase64String(base64StringFail).build());
currentTestCase.fail(CommonUtil.getStringForReport(result.getThrowable().getMessage()));
break;
case 3:
default:
//String screenshotSkip = commonUtil.getScreenShot(driver, result.getName());
String base64StringSkip= commonUtil.getImageAsBase64(driver,result.getName());
String base64StringSkip = commonUtil.getImageAsBase64(driver, result.getName());
currentTestCase.log(Status.FAIL, "TEST FAILED.REFER SCREENSHOT", MediaEntityBuilder.createScreenCaptureFromBase64String(base64StringSkip).build());
currentTestCase.skip("TEST SKIPPED ");
currentTestCase.skip(result.getThrowable());
Expand All @@ -175,8 +175,9 @@ public void cleanUp() throws Exception {
if (platform.isIOS() || platform.isAndroid())
mobileDriverAction.killApp();
extent.flush();
driver.quit();
if ((platform.isIOS() || platform.isAndroid())&&!executionMode.equalsIgnoreCase("cloud"))
if (driver != null)
driver.quit();
if ((platform.isIOS() || platform.isAndroid()) && !executionMode.equalsIgnoreCase("cloud"))
driverHelper.stopAppiumServer();
}

Expand Down
4 changes: 0 additions & 4 deletions testng.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,4 @@
<class name="com.ct.framework.testscripts.ios.TS_CT_SampleTest"/>
</classes>
</test>




</suite>

0 comments on commit db6f6d2

Please sign in to comment.