Skip to content

Commit

Permalink
Merge pull request #2 from codeandtheory/playwright-support
Browse files Browse the repository at this point in the history
Playwright support
  • Loading branch information
deepaktiwariyml authored Dec 19, 2024
2 parents 049be61 + db6f6d2 commit f50e058
Show file tree
Hide file tree
Showing 61 changed files with 487 additions and 1,636 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<junit.version>4.13.2</junit.version>
<webdrivermanager.version>5.9.2</webdrivermanager.version>
<lombok.version>1.18.26</lombok.version>
<microsoft.playwright.version>1.49.0</microsoft.playwright.version>
<rest-assured.version>5.4.0</rest-assured.version>
<rest-assured-schemavalidator.version>4.3.1</rest-assured-schemavalidator.version>
<box-jsonpatch.version>1.16</box-jsonpatch.version>
Expand Down Expand Up @@ -280,6 +281,11 @@
<version>1.1.1</version>
</dependency>

<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>${microsoft.playwright.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.browserstack</groupId>-->
<!-- <artifactId>browserstack-java-sdk</artifactId>-->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yml.framework.aut.commons;
package com.ct.framework.aut.commons;

public enum AppUiObjectNames {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yml.framework.aut.commons;
package com.ct.framework.aut.commons;

public class ApplicationConstants {
public static final long const_timeout_extra_small=3;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yml.framework.aut.commons;
package com.ct.framework.aut.commons;

public enum HomePageBottomTabs {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yml.framework.aut.pojo;
package com.ct.framework.aut.pojo;

import org.openqa.selenium.WebElement;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yml.framework.aut.pojo;
package com.ct.framework.aut.pojo;

public class User {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yml.framework.aut.rest;
package com.ct.framework.aut.rest;

public class ApiEndPoints {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yml.framework.aut.rest;
package com.ct.framework.aut.rest;

import org.json.JSONException;
import org.json.JSONObject;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.yml.framework.aut.screens;
package com.ct.framework.aut.screens;

import com.aventstack.extentreports.ExtentTest;
import com.google.inject.Inject;
import com.yml.framework.contracts.adapters.MobileDriverActionAdapter;
import com.yml.framework.common.Platform;
import com.ct.framework.contracts.adapters.MobileDriverActionAdapter;
import com.ct.framework.common.Platform;
import io.appium.java_client.pagefactory.AndroidFindBy;
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
import io.appium.java_client.pagefactory.iOSXCUITFindBy;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.PageFactory;
Expand Down Expand Up @@ -54,6 +55,11 @@ public void setCurrentTestCase(ExtentTest currentTestCase) {
@iOSXCUITFindBy(id = "searchText")
public WebElement screenTitle;

public WebElement findElementInsideShadowRoot(WebElement shadowHost, String cssSelector){
JavascriptExecutor js = (JavascriptExecutor) driver;
return (WebElement) js.executeScript(
"return arguments[0].shadowRoot.querySelector(arguments[1])", shadowHost, cssSelector);
}



Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yml.framework.aut.screens;
package com.ct.framework.aut.screens;

import com.google.inject.Inject;
import io.appium.java_client.pagefactory.AndroidFindBy;
Expand Down Expand Up @@ -51,5 +51,8 @@ public WelcomeScreen(WebDriver driver, Logger logger) {

@AndroidFindBy(id = "com.saloncentric.app:id/tv_register_discription")
@iOSXCUITFindBy(id = "registerNowButton")
public WebElement registerNowButton;
@FindBy(xpath = "//a[contains(@href,'health.c')]")
public WebElement healthLink;


}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.yml.framework.aut.screens.login;
package com.ct.framework.aut.screens.login;

import com.google.inject.Inject;
import com.yml.framework.aut.screens.BaseScreen;
import com.ct.framework.aut.screens.BaseScreen;
import io.appium.java_client.pagefactory.AndroidFindBy;
import io.appium.java_client.pagefactory.iOSXCUITFindBy;
import org.openqa.selenium.WebDriver;
Expand Down Expand Up @@ -64,12 +64,43 @@ public LoginScreen(WebDriver driver,Logger logger) {
@iOSXCUITFindBy(id = "Forgot Password?")
public WebElement noInternetErrorToastMsg;


@AndroidFindBy(xpath = "//android.widget.Toast[1]")
@iOSXCUITFindBy(id = "Forgot Password?")
@FindBy(xpath = "//a[text()='Sign in']")
public WebElement signInLink;

@AndroidFindBy(xpath = "//android.widget.Toast[1]")
@iOSXCUITFindBy(id = "Forgot Password?")
@FindBy(xpath = "(//ymlwebcl-textfield[@textfieldid='email'])[1]")
public WebElement emailShadowRoot;

@AndroidFindBy(xpath = "//android.widget.Toast[1]")
@iOSXCUITFindBy(id = "Forgot Password?")
@FindBy(xpath = "//ymlwebcl-textfield[@textfieldid='password']")
public WebElement passwordShadowRoot;

@AndroidFindBy(xpath = "//android.widget.Toast[1]")
@iOSXCUITFindBy(id = "Forgot Password?")
@FindBy(css = "#email")
public WebElement emailtextBox;

@AndroidFindBy(id = "com.saloncentric.app:id/ivNav")
@iOSXCUITFindBy(id = "product")
@FindBy(xpath = "(//ymlwebcl-button[@partname='button-filled button-fullWidth'])[1]")
public WebElement signinButtonShadowRoot;





public WebElement getInvalidEmailErrorToastMsg() {
return invalidEmailErrorToastMsg;
}




public boolean loginAction(String username, String password) throws Exception {

logger.info("Starting login Action");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yml.framework.common;
package com.ct.framework.common;


import com.aventstack.extentreports.ExtentTest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yml.framework.common;
package com.ct.framework.common;

public enum Direction {
UP,DOWN,LEFT,RIGHT;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yml.framework.common;
package com.ct.framework.common;

public class Platform {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yml.framework.common;
package com.ct.framework.common;

import com.aventstack.extentreports.markuputils.MarkupHelper;
import com.google.inject.Inject;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.yml.framework.contracts.adapters;
package com.ct.framework.contracts.adapters;

import com.aventstack.extentreports.ExtentTest;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import com.yml.framework.aut.commons.AppUiObjectNames;
import com.yml.framework.common.Direction;
import com.yml.framework.common.Platform;
import com.ct.framework.aut.commons.AppUiObjectNames;
import com.ct.framework.common.Direction;
import com.ct.framework.common.Platform;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.edge.EdgeDriver;
Expand Down Expand Up @@ -138,6 +138,21 @@ public List<WebElement> getWebElements(String locatorStrategy, String locator) {

}

public WebElement getElementInsideShadowRootById(WebElement parent, String id){

return parent.getShadowRoot().findElement(By.id(id));
}

public WebElement getElementInsideShadowRootByCssSelector(WebElement parent, String cssSelector){

return parent.getShadowRoot().findElement(By.cssSelector(cssSelector));
}

public WebElement getElementInsideShadowRootByXpath(WebElement parent, String xpath){

return parent.getShadowRoot().findElement(By.xpath(xpath));
}

public WebElement getWebElementByLocator(WebElement webElement, String locatorStrategy, String locator) {

WebElement element = null;
Expand Down Expand Up @@ -253,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 Expand Up @@ -422,6 +483,7 @@ public void waitAndClickMobileElement(String locatorStrategy, String locator, lo
}



public WebElement waitTillMobileElementClickable(String locatorStrategy, String locator, long timeOutInSeconds) {

WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(timeOutInSeconds));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.yml.framework.contracts.impl.android;
package com.ct.framework.contracts.impl.android;

import com.google.common.collect.ImmutableMap;
import com.yml.framework.common.Direction;
import com.yml.framework.contracts.adapters.MobileDriverActionAdapter;
import com.ct.framework.common.Direction;
import com.ct.framework.contracts.adapters.MobileDriverActionAdapter;
import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.connection.ConnectionStateBuilder;
Expand All @@ -20,7 +20,7 @@
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

import static com.yml.framework.aut.commons.ApplicationConstants.*;
import static com.ct.framework.aut.commons.ApplicationConstants.*;
import static freemarker.template.utility.Collections12.singletonList;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.yml.framework.contracts.impl.ios;
package com.ct.framework.contracts.impl.ios;

import com.yml.framework.common.Direction;
import com.yml.framework.contracts.adapters.MobileDriverActionAdapter;
import com.ct.framework.common.Direction;
import com.ct.framework.contracts.adapters.MobileDriverActionAdapter;
import io.appium.java_client.TouchAction;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.touch.WaitOptions;
Expand All @@ -15,8 +15,8 @@
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

import static com.yml.framework.aut.commons.ApplicationConstants.const_timeout_medium;
import static com.yml.framework.aut.commons.ApplicationConstants.const_timeout_small;
import static com.ct.framework.aut.commons.ApplicationConstants.const_timeout_medium;
import static com.ct.framework.aut.commons.ApplicationConstants.const_timeout_small;
import static freemarker.template.utility.Collections12.singletonList;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.yml.framework.contracts.impl.web;
package com.ct.framework.contracts.impl.web;

import com.yml.framework.common.Direction;
import com.yml.framework.contracts.adapters.MobileDriverActionAdapter;
import com.ct.framework.common.Direction;
import com.ct.framework.contracts.adapters.MobileDriverActionAdapter;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebElement;
Expand Down
Loading

0 comments on commit f50e058

Please sign in to comment.