Skip to content

Commit

Permalink
Update Remote
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdelrhman-Ellithy committed Dec 11, 2024
1 parent 0b0fabb commit fb0c519
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 60 deletions.
100 changes: 94 additions & 6 deletions Test-Output/Logs/Test.log
Original file line number Diff line number Diff line change
@@ -1,6 +1,94 @@
2024-12-04 22:04:30 DEBUG TestNG - suiteXmlPath: "C:\Users\lenovo\IdeaProjects\Ellithium\TestNGRunner.xml"
2024-12-04 22:04:31 INFO logsUtils - Getting Timestamp: 2024-12-04
2024-12-04 22:04:31 INFO logsUtils - Reading value for key: LastRunDate from JSON file: Test-Output\UpdateChecker\checker
2024-12-04 22:04:31 INFO logsUtils - Successfully read value for key: LastRunDate from JSON file: Test-Output\UpdateChecker\checker
2024-12-04 22:04:31 INFO logsUtils - Setting value for key: LastRunDate in JSON file: Test-Output\UpdateChecker\checker
2024-12-04 22:04:31 INFO logsUtils - Successfully updated JSON file: Test-Output\UpdateChecker\checker
2024-12-11 22:58:48 DEBUG TestNG - suiteXmlPath: "C:\Users\lenovo\IdeaProjects\Ellithium\TestNGRunner.xml"
2024-12-11 22:58:49 INFO Logger - Getting Timestamp: 2024-12-11
2024-12-11 22:58:49 INFO Logger - Reading value for key: LastRunDate from JSON file: Test-Output\UpdateChecker\checker
2024-12-11 22:58:49 ERROR AllureLifecycle - Could not start step: no test case running
2024-12-11 22:58:49 ERROR AllureLifecycle - Could not stop step: step with uuid e0aa492b-0fe3-42ae-bc21-d1f4011c53dd not found
2024-12-11 22:58:49 INFO Logger - Successfully read value for key: LastRunDate from JSON file: Test-Output\UpdateChecker\checker
2024-12-11 22:58:49 ERROR AllureLifecycle - Could not start step: no test case running
2024-12-11 22:58:49 ERROR AllureLifecycle - Could not stop step: step with uuid bd753d9c-b012-4919-af6f-45ea5e89bf1f not found
2024-12-11 22:58:49 INFO Logger - Successfully loaded properties file: src\main\resources\properties\config
2024-12-11 22:58:49 ERROR AllureLifecycle - Could not start step: no test case running
2024-12-11 22:58:49 ERROR AllureLifecycle - Could not stop step: step with uuid f5108031-3522-4425-aec3-1012c7873255 not found
2024-12-11 22:58:49 INFO Logger - Initialize default Timeout for Element 
2024-12-11 22:58:49 ERROR AllureLifecycle - Could not start step: no test case running
2024-12-11 22:58:49 ERROR AllureLifecycle - Could not stop step: step with uuid d6c03f7c-128a-4b57-9295-ae37b7896a6a not found
2024-12-11 22:58:49 INFO Logger - Successfully loaded properties file: src\main\resources\properties\config
2024-12-11 22:58:49 ERROR AllureLifecycle - Could not start step: no test case running
2024-12-11 22:58:49 ERROR AllureLifecycle - Could not stop step: step with uuid 64d411a4-746c-4437-91d3-f490dec5d5a7 not found
2024-12-11 22:58:49 INFO Logger - Initialize default Polling Time for Element 
2024-12-11 22:58:49 ERROR AllureLifecycle - Could not start step: no test case running
2024-12-11 22:58:49 ERROR AllureLifecycle - Could not stop step: step with uuid 8f8affe7-0a62-4858-8eae-6d14c238d0b6 not found
2024-12-11 22:58:49 INFO Logger - Successfully loaded properties file: src\main\resources\properties\config
2024-12-11 22:58:49 ERROR AllureLifecycle - Could not start step: no test case running
2024-12-11 22:58:49 ERROR AllureLifecycle - Could not stop step: step with uuid af0dfe93-706b-4663-ba7e-647d86440594 not found
2024-12-11 22:58:49 INFO Logger - Initialize default Implicit Wait for the Driver 
2024-12-11 22:58:49 ERROR AllureLifecycle - Could not start step: no test case running
2024-12-11 22:58:49 ERROR AllureLifecycle - Could not stop step: step with uuid 747c97a6-f635-4219-9df2-a5227288bdb8 not found
2024-12-11 22:58:49 INFO Logger - Successfully loaded properties file: src\main\resources\properties\config
2024-12-11 22:58:49 ERROR AllureLifecycle - Could not start step: no test case running
2024-12-11 22:58:49 ERROR AllureLifecycle - Could not stop step: step with uuid 48fbd617-398d-4465-89d5-4f66fb565531 not found
2024-12-11 22:58:49 INFO Logger - ---------------------------------------------
2024-12-11 22:58:49 INFO Logger - ------- Ellithium Engine Setup -------------
2024-12-11 22:58:49 INFO Logger - ---------------------------------------------
2024-12-11 22:58:49 INFO Logger - Successfully loaded properties file: src\main\resources\properties\allure
2024-12-11 22:58:49 TRACE Graph - [Graph] ADDING NODE BaseRemote.Setup()[pri:0, instance:null] -152046584
2024-12-11 22:58:49 TRACE Graph - [Graph] ================ SORTING
2024-12-11 22:58:49 TRACE Graph - [Graph] =============== DONE SORTING
2024-12-11 22:58:49 TRACE Graph - [Graph] ====== SORTED NODES
2024-12-11 22:58:49 TRACE Graph - [Graph] ====== END SORTED NODES
2024-12-11 22:58:49 TRACE Graph - [Graph] ADDING NODE BaseRemote.tareDown()[pri:0, instance:null] 391358389
2024-12-11 22:58:49 TRACE Graph - [Graph] ================ SORTING
2024-12-11 22:58:49 TRACE Graph - [Graph] =============== DONE SORTING
2024-12-11 22:58:49 TRACE Graph - [Graph] ====== SORTED NODES
2024-12-11 22:58:49 TRACE Graph - [Graph] ====== END SORTED NODES
2024-12-11 22:58:49 TRACE Graph - [Graph] ADDING NODE loginTestsRemote.validLogin()[pri:2, instance:Tests.loginTestsRemote@46d9aec8] 832491811
2024-12-11 22:58:49 TRACE Graph - [Graph] ADDING NODE loginTestsRemote.invalidLogin(java.lang.String,java.lang.String,java.lang.String)[pri:1, instance:Tests.loginTestsRemote@46d9aec8] -686925744
2024-12-11 22:58:49 TRACE Graph - [Graph] ================ SORTING
2024-12-11 22:58:49 TRACE Graph - [Graph] =============== DONE SORTING
2024-12-11 22:58:49 TRACE Graph - [Graph] ====== SORTED NODES
2024-12-11 22:58:49 TRACE Graph - [Graph] ====== END SORTED NODES
2024-12-11 22:58:49 INFO Logger - [SUITE STARTED]: FRAMEWORK TEST [SUITE STARTED]
2024-12-11 22:58:49 INFO Logger - [ALL TESTS STARTED]: WEB UI TEST CHROME [ALL TESTS STARTED]
2024-12-11 22:58:49 INFO Logger - Chrome Options Configured
2024-12-11 22:58:52 INFO Logger - Driver Created
2024-12-11 22:58:52 ERROR AllureLifecycle - Could not update test case: no test case running
2024-12-11 22:58:52 INFO Logger - [START] TESTCASE invalidLogin [STARTED]
2024-12-11 22:58:52 INFO Logger - Navigating to URL: https://the-internet.herokuapp.com/
2024-12-11 22:58:55 INFO Logger - Clicked on element: 
2024-12-11 22:58:55 INFO Logger - Sent Data: "tomsmith" into Username.
2024-12-11 22:58:56 INFO Logger - Sent Data: "hamada" into Password.
2024-12-11 22:58:57 INFO Logger - Clicked on element: 
2024-12-11 22:58:57 INFO Logger - [PASSED] TESTCASE invalidLogin [PASSED]
2024-12-11 22:58:57 INFO Logger - [START] TESTCASE invalidLogin [STARTED]
2024-12-11 22:58:57 INFO Logger - Navigating to URL: https://the-internet.herokuapp.com/
2024-12-11 22:58:57 INFO Logger - Clicked on element: 
2024-12-11 22:58:58 INFO Logger - Sent Data: "hamada" into Username.
2024-12-11 22:58:58 INFO Logger - Sent Data: "SuperSecretPassword!" into Password.
2024-12-11 22:58:58 INFO Logger - Clicked on element: 
2024-12-11 22:58:58 INFO Logger - [PASSED] TESTCASE invalidLogin [PASSED]
2024-12-11 22:58:58 INFO Logger - [START] TESTCASE validLogin [STARTED]
2024-12-11 22:58:58 INFO Logger - Navigating to URL: https://the-internet.herokuapp.com/
2024-12-11 22:58:59 INFO Logger - Clicked on element: 
2024-12-11 22:58:59 INFO Logger - Sent Data: "SuperSecretPassword!" into Password.
2024-12-11 22:58:59 INFO Logger - Sent Data: "tomsmith" into Username.
2024-12-11 22:59:00 INFO Logger - Clicked on element: 
2024-12-11 22:59:00 INFO Logger - [PASSED] TESTCASE validLogin [PASSED]
2024-12-11 22:59:00 INFO Logger - WebDriver quit
2024-12-11 22:59:00 ERROR AllureLifecycle - Could not update test case: no test case running
2024-12-11 22:59:00 INFO Logger - [ALL TESTS COMPLETED]: WEB UI TEST CHROME [ALL TESTS COMPLETED]
2024-12-11 22:59:00 INFO Logger - [SUITE FINISHED]: FRAMEWORK TEST [SUITE FINISHED]
2024-12-11 22:59:01 INFO Logger - Total Execution Time is: 0 Min 11 Sec 602 Mills
2024-12-11 22:59:01 INFO Logger - ------------------------------------------
2024-12-11 22:59:01 INFO Logger - ------- Ellithium Engine TearDown -------
2024-12-11 22:59:01 INFO Logger - ------------------------------------------
2024-12-11 22:59:01 INFO Logger - Successfully loaded properties file: src\main\resources\properties\allure
2024-12-11 22:59:01 INFO Logger - Successfully loaded properties file: src\main\resources\properties\allure
2024-12-11 22:59:01 INFO Logger - Successfully loaded properties file: src\main\resources\properties\allure
2024-12-11 22:59:01 INFO Logger - Allure folder exists at: C:\Users\lenovo\.m2\repository\allure-Ellithium
2024-12-11 22:59:01 INFO Logger - Found Allure binary directory: C:\Users\lenovo\.m2\repository\allure-Ellithium\-2.30.0\bin
2024-12-11 22:59:01 INFO Logger - Attempting to execute command: C:\Users\lenovo\.m2\repository\allure-Ellithium\-2.30.0\bin\allure generate --single-file --name "Test Report" -o .\LastReport\ .\Test-Output/Reports/Allure/allure-results\
2024-12-11 22:59:03 INFO Logger - Command executed successfully. Exit code: 0
2024-12-11 22:59:03 INFO Logger - Getting Timestamp: 2024-12-11-10-59-03PM
2024-12-11 22:59:03 INFO Logger - Successfully loaded properties file: src\main\resources\properties\allure
2024-12-11 22:59:03 INFO Logger - Attempting to execute command: start Test-Output\Reports\Allure\allure-report\Ellithium-Test-Report-2024-12-11-10-59-03PM.html
2024-12-11 22:59:03 INFO Logger - Command executed successfully. Exit code: 0
2 changes: 1 addition & 1 deletion Test-Output/UpdateChecker/checker.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"LastRunDate": "2024-12-04"
"LastRunDate": "2024-12-11"
}
15 changes: 1 addition & 14 deletions TestNGRunner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,8 @@
<!-- </classes>-->
<!-- </test>-->
<test name="Web UI Test Chrome">
<parameter name="BrowserName" value="Chrome"></parameter>
<classes>
<class name="Tests.loginTests"/>
</classes>
</test>
<test name="Web UI Test FireFox">
<parameter name="BrowserName" value="FireFox"></parameter>
<classes>
<class name="Tests.loginTests"/>
</classes>
</test>
<test name="Web UI Test Edge">
<parameter name="BrowserName" value="Edge"></parameter>
<classes>
<class name="Tests.loginTests"/>
<class name="Tests.loginTestsRemote"/>
</classes>
</test>
<!-- <test name="ِDatabase Test">-->
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Ellithium/core/driver/BrowserSetUp.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static WebDriver setupLocalDriver(DriverType driverType, HeadlessMode hea
return null;
}
}
public static WebDriver setupRemoteDriver(DriverType driverType, URL remoteAddress, Capabilities capabilities, HeadlessMode headlessMode, PageLoadStrategyMode pageLoadStrategy, PrivateMode privateMode, SandboxMode sandboxMode, WebSecurityMode webSecurityMode) {
public static RemoteWebDriver setupRemoteDriver(DriverType driverType, URL remoteAddress, Capabilities capabilities, HeadlessMode headlessMode, PageLoadStrategyMode pageLoadStrategy, PrivateMode privateMode, SandboxMode sandboxMode, WebSecurityMode webSecurityMode) {
RemoteWebDriver driver;
switch (driverType) {
case REMOTE_Chrome->{
Expand Down
62 changes: 36 additions & 26 deletions src/main/java/Ellithium/core/driver/DriverFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static io.appium.java_client.proxy.Helpers.createProxy;

public class DriverFactory {
private static ThreadLocal<RemoteWebDriver> RemoteWebDriverThreadLocal= new ThreadLocal<>();;
private static ThreadLocal<WebDriver> WebDriverThread = new ThreadLocal<>();
private static ThreadLocal<AndroidDriver> AndroidDriverThread = new ThreadLocal<>();
private static ThreadLocal<IOSDriver> IOSDriverThread = new ThreadLocal<>();
Expand Down Expand Up @@ -94,7 +95,7 @@ public static <T extends RemoteWebDriver> T getNewRemoteWebDriver(DriverType dri
ConfigContext.setCapabilities(capabilities);
ConfigContext.setRemoteAddress(remoteAddress);
webSetUp();
return (T) WebDriverThread.get();
return (T)RemoteWebDriverThreadLocal.get();
}
@SuppressWarnings("unchecked")
public static <T extends RemoteWebDriver> T getNewRemoteWebDriver(DriverType driverType, URL remoteAddress, Capabilities capabilities, HeadlessMode headlessMode, PrivateMode privateMode, PageLoadStrategyMode pageLoadStrategyMode, WebSecurityMode webSecurityMode) {
Expand Down Expand Up @@ -178,46 +179,55 @@ private static void webSetUp() {
var PrivateMode=ConfigContext.getPrivateMode();
var SandboxMode=ConfigContext.getSandboxMode();
var WebSecurityMode=ConfigContext.getWebSecurityMode();
WebDriver localDriver ;
switch (driverType){
case REMOTE_Edge,REMOTE_Safari,REMOTE_FireFox,REMOTE_Chrome ->{
var capabilities=ConfigContext.getCapabilities();
var remoteAddress=ConfigContext.getRemoteAddress();
localDriver=BrowserSetUp.setupRemoteDriver(driverType,remoteAddress,capabilities, headlessMode,PageLoadStrategy,PrivateMode,SandboxMode,WebSecurityMode);
var localDriver=BrowserSetUp.setupRemoteDriver(driverType,remoteAddress,capabilities, headlessMode,PageLoadStrategy,PrivateMode,SandboxMode,WebSecurityMode);
localDriver.manage().timeouts().implicitlyWait(Duration.ofSeconds(WaitManager.getDefaultImplicitWait()));
RemoteWebDriverThreadLocal.set(getDecoratedWebDriver(localDriver));
if(RemoteWebDriverThreadLocal!=null){
Reporter.log("Driver Created", LogLevel.INFO_GREEN);
}
else {
Reporter.log("Driver Creation Failed",LogLevel.INFO_RED);
}
}
default-> {
localDriver= BrowserSetUp.setupLocalDriver(driverType, headlessMode,PageLoadStrategy,PrivateMode,SandboxMode,WebSecurityMode);
}
}
String loggerExtensiveTraceModeFlag=PropertyHelper.getDataFromProperties(ConfigContext.getConfigFilePath(), "loggerExtensiveTraceMode");
if (loggerExtensiveTraceModeFlag.equalsIgnoreCase("true")){
DevTools devTools;
switch (driverType){
case Edge, REMOTE_Edge->{
devTools=((EdgeDriver)localDriver).getDevTools();
logDevTools(devTools);
var localDriver= BrowserSetUp.setupLocalDriver(driverType, headlessMode,PageLoadStrategy,PrivateMode,SandboxMode,WebSecurityMode);
String loggerExtensiveTraceModeFlag=PropertyHelper.getDataFromProperties(ConfigContext.getConfigFilePath(), "loggerExtensiveTraceMode");
if (loggerExtensiveTraceModeFlag.equalsIgnoreCase("true")){
DevTools devTools;
switch (driverType){
case Edge->{
devTools=((EdgeDriver)localDriver).getDevTools();
logDevTools(devTools);
}
case Chrome->{
devTools=((ChromeDriver)localDriver).getDevTools();
logDevTools(devTools);
}
}
}
case Chrome, REMOTE_Chrome->{
devTools=((ChromeDriver)localDriver).getDevTools();
logDevTools(devTools);
localDriver.manage().timeouts().implicitlyWait(Duration.ofSeconds(WaitManager.getDefaultImplicitWait()));
WebDriverThread.set(getDecoratedWebDriver(localDriver));
if(WebDriverThread!=null){
Reporter.log("Driver Created", LogLevel.INFO_GREEN);
}
else {
Reporter.log("Driver Creation Failed",LogLevel.INFO_RED);
}
}
}
assert localDriver != null;
localDriver.manage().timeouts().implicitlyWait(Duration.ofSeconds(WaitManager.getDefaultImplicitWait()));
WebDriverThread.set(getDecoratedWebDriver(localDriver));
if(WebDriverThread!=null){
Reporter.log("Driver Created", LogLevel.INFO_GREEN);
}
else {
Reporter.log("Driver Creation Failed",LogLevel.INFO_RED);
}
}
@SuppressWarnings("unchecked")
private static WebDriver getDecoratedWebDriver(WebDriver driver){
return new EventFiringDecorator<>(org.openqa.selenium.WebDriver.class, new seleniumListener()).decorate(driver);
}

@SuppressWarnings("unchecked")
private static RemoteWebDriver getDecoratedWebDriver(RemoteWebDriver driver){
return new EventFiringDecorator<>(org.openqa.selenium.remote.RemoteWebDriver.class, new seleniumListener()).decorate(driver);
}
private static AndroidDriver getDecoratedAndroidDriver(URL remoteAddress, Capabilities capabilities){
return createProxy(
AndroidDriver.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
Reporter.attachScreenshotToReport(screenShot, screenShot.getName(),
driverName,testResult.getName());
}
Reporter.addParams(GeneralHandler.getParameters());
}
Reporter.addParams(GeneralHandler.getParameters());
}
@Override
public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {
Expand Down
29 changes: 29 additions & 0 deletions src/test/java/Base/BaseRemote.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package Base;

import Ellithium.core.driver.DriverFactory;
import Ellithium.core.driver.DriverType;
import Pages.HomPage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;

import java.net.MalformedURLException;
import java.net.URL;

public class BaseRemote {
protected WebDriver driver;
protected HomPage home;
@BeforeClass
public void Setup() throws MalformedURLException {
DesiredCapabilities capabilities=new DesiredCapabilities();
driver= DriverFactory.getNewRemoteWebDriver(DriverType.REMOTE_Chrome ,new URL("http://localhost:4444/wd/hub"),capabilities);
home=new HomPage(driver);
}
@AfterClass
public void tareDown(){
driver.quit();;
}
}
12 changes: 2 additions & 10 deletions src/test/java/Base/BaseTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,12 @@
import org.openqa.selenium.WebDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Parameters;
public class BaseTests extends NonBDDSetup {
protected WebDriver driver;
protected HomPage home;
@Parameters({"BrowserName"})
@BeforeClass
public void Setup(String BrowserName){
DriverType type;
switch(BrowserName.toLowerCase()){
case "edge"->type=DriverType.Edge;
case "firefox"->type=DriverType.FireFox;
default -> {type=DriverType.Chrome;}
}
driver= DriverFactory.getNewLocalWebDriver(type, HeadlessMode.False, PrivateMode.True, PageLoadStrategyMode.Normal,WebSecurityMode.SecureMode,SandboxMode.Sandbox);
public void Setup(){
driver= DriverFactory.getNewLocalWebDriver(DriverType.Chrome, HeadlessMode.False, PrivateMode.True, PageLoadStrategyMode.Normal,WebSecurityMode.SecureMode,SandboxMode.Sandbox);
home=new HomPage(driver);
}
@AfterClass
Expand Down
1 change: 0 additions & 1 deletion src/test/java/Pages/SecureAreaPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public class SecureAreaPage {
DriverActions driverActions;
public SecureAreaPage(WebDriver Driver){
driver=Driver;

driverActions=new DriverActions(driver);
}
public String getLoginMassega(){
Expand Down
Loading

0 comments on commit fb0c519

Please sign in to comment.