Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdelrhman-Ellithy committed Nov 20, 2024
1 parent c755f41 commit 9c7ce5b
Show file tree
Hide file tree
Showing 8 changed files with 2,200 additions and 37 deletions.
1,091 changes: 1,091 additions & 0 deletions src/main/java/Ellithium/Utilities/interactions/AndroidDriverActions.java

Large diffs are not rendered by default.

1,092 changes: 1,092 additions & 0 deletions src/main/java/Ellithium/Utilities/interactions/IOSDriverActions.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
import Ellithium.Utilities.generators.TestDataGenerator;
import Ellithium.Utilities.helpers.PropertyHelper;
import Ellithium.config.managment.ConfigContext;
import Ellithium.core.driver.DriverType;
import Ellithium.core.logging.LogLevel;
import Ellithium.core.logging.logsUtils;
import Ellithium.core.reporting.Reporter;
import com.google.common.io.Files;
import io.appium.java_client.AppiumFluentWait;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.ios.IOSDriver;
import io.qameta.allure.Allure;
import io.qameta.allure.model.Status;
import org.openqa.selenium.*;
Expand All @@ -24,23 +20,14 @@
import java.util.*;
import java.util.concurrent.ExecutionException;

public class DriverActions<T extends WebDriver>{
public class WebDriverActions {
private int defaultTimeout= 5;
private int defaultPollingTime=500;
private boolean defaultTimeoutGotFlag=false;
private boolean defaultPollingTimeGotFlag=false;
private final T driver;
private final DriverType driverType;
public DriverActions(T driver) {
private final WebDriver driver;
public WebDriverActions(WebDriver driver) {
this.driver = driver;

if (driver instanceof AndroidDriver) {
driverType = DriverType.Android;
} else if (driver instanceof IOSDriver) {
driverType = DriverType.IOS;
} else {
driverType = DriverType.Chrome;
}
}
public void sendData( By locator, String data, int timeout, int pollingEvery) {
getFluentWait(timeout,pollingEvery)
Expand Down Expand Up @@ -324,18 +311,11 @@ public List<String> getTextFromMultipleElements( By locator, int timeout, int p
}
return texts;
}
public FluentWait<T> getFluentWait(int timeoutInSeconds, int pollingEveryInMillis) {
if ((driverType==DriverType.Android)||(driverType==DriverType.IOS)) {
return new AppiumFluentWait<>((T) driver)
.withTimeout(Duration.ofSeconds(timeoutInSeconds))
.pollingEvery(Duration.ofMillis(pollingEveryInMillis))
.ignoreAll(expectedExceptions);
} else {
public FluentWait<WebDriver> getFluentWait(int timeoutInSeconds, int pollingEveryInMillis) {
return new FluentWait<>(driver)
.withTimeout(Duration.ofSeconds(timeoutInSeconds))
.pollingEvery(Duration.ofMillis(pollingEveryInMillis))
.ignoreAll(expectedExceptions);
}
}
public List<String> getAttributeFromMultipleElements( By locator,String Attribute, int timeout, int pollingEvery) {
Reporter.log("Getting Attribute from multiple elements located: ",LogLevel.INFO_BLUE,locator.toString());
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/Base/AppiumBase.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package Base;

import Ellithium.Utilities.interactions.DriverActions;
import Ellithium.Utilities.interactions.WebDriverActions;
import Ellithium.core.base.NonBDDSetup;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.service.local.AppiumDriverLocalService;
Expand All @@ -13,7 +13,7 @@
public class AppiumBase extends NonBDDSetup {
protected AndroidDriver androidDriver;
protected AppiumDriverLocalService serviceBuilder;
protected DriverActions driverActions;
protected WebDriverActions driverActions;
@BeforeClass
public void setup() {
String appiumMainJsPath=System.getProperty("user.home").concat("\\AppData\\Roaming\\npm\\node_modules\\appium\\build\\lib\\main.js");
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/Pages/LoginPage.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package Pages;

import Ellithium.Utilities.interactions.DriverActions;
import Ellithium.Utilities.interactions.WebDriverActions;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
public class LoginPage {
WebDriver driver;
DriverActions driverActions;
WebDriverActions driverActions;
public LoginPage(WebDriver driver) {
this.driver=driver;
driverActions=new DriverActions(driver);
driverActions=new WebDriverActions(driver);
}
public void setUserName(String username){
driverActions.sendData(By.id("username"),username);
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/Pages/SearchPage.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package Pages;

import Ellithium.Utilities.interactions.DriverActions;
import Ellithium.Utilities.interactions.WebDriverActions;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
Expand All @@ -9,10 +9,10 @@

public class SearchPage {
WebDriver driver;
DriverActions driverActions;
WebDriverActions driverActions;
public SearchPage(WebDriver driver){
this.driver=driver;
driverActions=new DriverActions(driver);
driverActions=new WebDriverActions(driver);
}
public void searchItem(String itemName){
driverActions.sendData(By.id("searchBar"),itemName );
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/Pages/SecureAreaPage.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package Pages;

import Ellithium.Utilities.interactions.DriverActions;
import Ellithium.Utilities.interactions.WebDriverActions;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
public class SecureAreaPage {
WebDriver driver;
DriverActions driverActions;
WebDriverActions driverActions;
public SecureAreaPage(WebDriver Driver){
driver=Driver;

driverActions=new DriverActions(driver);
driverActions=new WebDriverActions(driver);
}
public String getLoginMassega(){
return driverActions.getText(By.id("flash"));
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/Tests/AppiumTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package Tests;

import Base.AppiumBase;
import Ellithium.Utilities.interactions.DriverActions;
import Ellithium.Utilities.interactions.WebDriverActions;
import Ellithium.core.driver.DriverFactory;
import Ellithium.core.driver.DriverType;
import io.appium.java_client.AppiumBy;
Expand All @@ -19,7 +19,7 @@ public void SmokeMobileTest() throws MalformedURLException, InterruptedException
options.setAppActivity("com.appyinnovate.e_invoice.MainActivity");
options.setAppPackage("com.appyinnovate.e_invoice");
androidDriver= DriverFactory.getNewDriver(DriverType.Android,new URL("http://0.0.0.0:4723"),options);
driverActions=new DriverActions(androidDriver);
driverActions=new WebDriverActions(androidDriver);
driverActions.clickOnElement(AppiumBy.accessibilityId("English - الإنجليزية "),5,200);
Assert.assertTrue(false);
}
Expand Down

0 comments on commit 9c7ce5b

Please sign in to comment.