Skip to content

Commit

Permalink
Merge pull request #41 from ing-bank/IPS-MobileTesting-Addition
Browse files Browse the repository at this point in the history
Mobile Testing Capabilities
  • Loading branch information
ghoshasish99 authored Dec 14, 2024
2 parents 068d0b5 + 1548b55 commit 4dc7654
Show file tree
Hide file tree
Showing 142 changed files with 7,849 additions and 676 deletions.
4 changes: 4 additions & 0 deletions Datalib/src/main/java/com/ing/datalib/or/mobile/MobileOR.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public class MobileOR implements ORRootInf<MobileORPage> {
"id",
"Accessibility",
"xpath",
"css",
"name",
"tagName",
"link_text",
"class"));

@JacksonXmlProperty(isAttribute = true, localName = "ref")
Expand Down
24 changes: 24 additions & 0 deletions Engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,30 @@
<version>${commons-lang3.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>${ioAppium.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.galenframework</groupId>
<artifactId>galen-core</artifactId>
<version>2.4.4</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.ashot</groupId>
<artifactId>ashot</artifactId>
<version>1.5.4</version>
<type>jar</type>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.ing.engine.commands.aXe;

import com.ing.engine.commands.General;
import com.ing.engine.commands.browser.General;
import com.ing.engine.core.CommandControl;
import com.deque.html.axecore.playwright.*;
import com.deque.html.axecore.results.AxeResults;
import com.deque.html.axecore.playwright.Reporter;
import com.ing.engine.commands.Performance;
import com.ing.engine.commands.browser.Performance;
import com.ing.engine.constants.FilePath;
import com.ing.engine.support.Status;
import com.ing.engine.support.methodInf.Action;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ing.engine.commands;
package com.ing.engine.commands.browser;

import com.ing.engine.core.CommandControl;
import com.ing.engine.execution.exception.ActionException;
import com.ing.engine.execution.exception.ForcedException;
import com.ing.engine.support.Status;
import com.ing.engine.support.methodInf.Action;
Expand Down Expand Up @@ -638,7 +639,7 @@ public void assertElementIsNotVisible() {
assertionLogging(err, "[" + ObjectName + "] is visible");
}
}

/**
* *************************************************************************************************************
*/
Expand All @@ -651,6 +652,8 @@ public void assertPageTitleMatches() {
} catch (AssertionFailedError e) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, e);
Report.updateTestLog("Assertion Failed", "Page does not have title matching '" + Data + "'", Status.FAIL);
} catch (PlaywrightException e) {
throw new ActionException(e);
}
}

Expand All @@ -663,12 +666,15 @@ public void assertPageURLMatches() {
} catch (AssertionFailedError e) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, e);
Report.updateTestLog("Assertion Failed", "Page does not have URL matching '" + Data + "'", Status.FAIL);
} catch (PlaywrightException e) {
throw new ActionException(e);
}
}

private void PlaywrightExceptionLogging(PlaywrightException e) {
Report.updateTestLog(Action, "Unique Element [" + ObjectName + "] not found on Page. Error :" + e.getMessage(), Status.FAIL);
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, e);
throw new ActionException(e);
}

private void assertionLogging(AssertionFailedError err, String message) {
Expand All @@ -694,12 +700,12 @@ public void assertVariable() throws RuntimeException {
if (strAns.equals(strTemp[1])) {
System.out.println("Condition '" + Input + "' is true ");
Report.updateTestLog("assertVariable",
"Variable value matches with provided data "+strTemp[1], Status.PASSNS);
"Variable value matches with provided data " + strTemp[1], Status.PASSNS);

} else {
System.out.println("Condition '" + Input + "' is false ");
Report.updateTestLog("assertVariable",
"Variable value is "+strAns+" but expected value is "+strTemp[1], Status.FAILNS);
"Variable value is " + strAns + " but expected value is " + strTemp[1], Status.FAILNS);
}
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
Expand Down Expand Up @@ -731,11 +737,12 @@ public void assertVariableFromDataSheet() throws RuntimeException {
throw new ForcedException("assertVariableFromDataSheet", e.getMessage());
}
}

private void highlightElement() {
Locator.scrollIntoViewIfNeeded();
Locator.evaluate("element => element.style.outline = '2px solid red'");
}

private void removeHighlightFromElement() {
Locator.evaluate("element => element.style.outline = ''");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ing.engine.commands;
package com.ing.engine.commands.browser;

import com.ing.engine.core.CommandControl;
import com.ing.engine.execution.exception.ActionException;
import com.ing.engine.execution.exception.ForcedException;
import com.ing.engine.support.Status;
import com.ing.engine.support.methodInf.Action;
Expand Down Expand Up @@ -72,6 +73,7 @@ public void GoForward() {
} catch (Exception e) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, e);
Report.updateTestLog(Action, e.getMessage(), Status.FAIL);
throw new ActionException(e);
}

}
Expand All @@ -88,6 +90,7 @@ public void GoBack() {
} catch (Exception e) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, e);
Report.updateTestLog(Action, e.getMessage(), Status.FAIL);
throw new ActionException(e);
}

}
Expand All @@ -104,6 +107,7 @@ public void Reload() {
} catch (Exception e) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, e);
Report.updateTestLog(Action, e.getMessage(), Status.FAIL);
throw new ActionException(e);
}

}
Expand All @@ -116,6 +120,7 @@ public void RecordFromHere() {
} catch (Exception e) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, e);
Report.updateTestLog(Action, e.getMessage(), Status.FAIL);
throw new ActionException(e);
}
}

Expand All @@ -127,6 +132,7 @@ public void ClosePage() {
} catch (Exception e) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, e);
Report.updateTestLog(Action, e.getMessage(), Status.FAIL);
throw new ActionException(e);
}
}

Expand All @@ -138,6 +144,7 @@ public void CloseBrowserContext() {
} catch (Exception e) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, e);
Report.updateTestLog(Action, e.getMessage(), Status.FAIL);
throw new ActionException(e);
}
}

Expand All @@ -148,7 +155,7 @@ public void setDefaultTimeout() {
Page.setDefaultTimeout(timeout);
Report.updateTestLog(Action, "Default timeout changed to [" + Data + "] millisecond/s", Status.DONE);
} else {
Report.updateTestLog(Action, "Couldn't change default timeout (invalid input) " + Data, Status.DEBUG);
Report.updateTestLog(Action, "Couldn't change default timeout (invalid input) " + Data, Status.DEBUG);
}
}

Expand Down Expand Up @@ -215,6 +222,7 @@ public void setViewPortSize() {
} catch (Exception ex) {
Report.updateTestLog(Action, "Unable to change viewport size ", Status.FAIL);
Logger.getLogger(Basic.class.getName()).log(Level.SEVERE, null, ex);
throw new ActionException(ex);
}
}

Expand Down Expand Up @@ -457,6 +465,7 @@ private void PlaywrightExceptionLogging(PlaywrightException e) {
Report.updateTestLog(Action, "Unique Element [" + ObjectName + "] not found on Page. Error :" + e.getMessage(),
Status.FAIL);
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, e);
throw new ActionException(e);
}

public void replaceFunction() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ing.engine.commands;
package com.ing.engine.commands.browser;

import com.ing.engine.core.CommandControl;
import com.ing.engine.execution.exception.ActionException;
import com.ing.engine.support.Status;
import com.ing.engine.support.methodInf.Action;
import com.ing.engine.support.methodInf.InputType;
Expand Down Expand Up @@ -71,17 +72,26 @@ public void SetChecked() {
} catch (PlaywrightException e) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, e);
Report.updateTestLog("Could not perfom [" + Action + "] action", "Error: " + e.getMessage(), Status.FAIL);
throw new ActionException(e);
}
}

@Action(object = ObjectType.PLAYWRIGHT, desc = "Check [<Object>] if visible", input = InputType.YES)
public void CheckifVisible() {
try
{
Page.waitForLoadState();
if (Locator.isVisible()) {
Check();
} else {
Report.updateTestLog(Action, "[" + ObjectName + "]" + " is not visible", Status.DONE);
}
}
catch (PlaywrightException e) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, e);
Report.updateTestLog(Action, "Unique Element [" + ObjectName + "] not found on Page. Error :" + e.getMessage(), Status.FAIL);
throw new ActionException(e);
}
}

@Action(object = ObjectType.PLAYWRIGHT, desc = "Check/Uncheck the [<Object>] element based on Data", input = InputType.YES)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ing.engine.commands;
package com.ing.engine.commands.browser;

import com.ing.datalib.or.common.ObjectGroup;
import com.ing.datalib.or.image.ImageORObject;
Expand All @@ -20,8 +20,14 @@
import java.util.Map;
import java.util.Stack;

//Added for Mobile
import com.ing.engine.drivers.MobileDriver;
import com.ing.engine.drivers.MobileObject;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class Command {

public Page Page;
public Playwright Playwright;
public BrowserContext BrowserContext;
Expand All @@ -39,6 +45,10 @@ public class Command {
public String Reference;
private final CommandControl Commander;
public UserDataAccess userData;
//Added for Mobile
public WebDriver mDriver;
public WebElement Element;
public MobileObject mObject;

/**
* ******API*******
Expand Down Expand Up @@ -76,6 +86,24 @@ public class Command {
*/
public Command(CommandControl cc) {
Commander = cc;
if(Commander.mobileDriver!=null)
{
mDriver = Commander.mobileDriver.driver;
mObject = Commander.MObject;
Data = Commander.Data;
ObjectName = Commander.ObjectName;
Element = Commander.Element;
imageObjectGroup = Commander.imageObjectGroup;
Description = Commander.Description;
Condition = Commander.Condition;
Input = Commander.Input;
Report = Commander.Report;
Reference = Commander.Reference;
Action = Commander.Action;
userData = Commander.userData;
}
else
{
Page = Commander.Page.page;
Playwright = Commander.Playwright.playwright;
BrowserContext = Commander.BrowserContext.browserContext;
Expand All @@ -92,7 +120,7 @@ public Command(CommandControl cc) {
Reference = Commander.Reference;
Action = Commander.Action;
userData = Commander.userData;

}
/**
* ******Webservice*******
*/
Expand Down Expand Up @@ -130,7 +158,7 @@ public String getDataBaseData(String key) {
public Stack<Locator> getRunTimeElement() {
return Commander.getRunTimeElement();
}

public void executeMethod(String Action) {
Commander.executeAction(Action);
}
Expand All @@ -154,9 +182,21 @@ public void executeMethod(Locator Locator, String Action) {
public PlaywrightDriver getDriverControl() {
return Commander.Page;
}

public MobileDriver getMobileDriverControl()
{
return Commander.mobileDriver;
}

public Boolean isDriverAlive() {
if(mDriver!=null)
{
return getMobileDriverControl().isAlive();
}
else
{
return getDriverControl().isAlive();
}
}

private void setElement(Locator Locator) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

package com.ing.engine.commands;
package com.ing.engine.commands.browser;

import com.ing.engine.core.CommandControl;
import com.ing.engine.execution.exception.ActionException;
import com.ing.engine.support.Status;
import com.ing.engine.support.methodInf.Action;
import com.ing.engine.support.methodInf.InputType;
Expand Down Expand Up @@ -33,6 +34,7 @@ public void TakeElementScreenshot() {
} catch (Exception e) {
Report.updateTestLog(Action, e.getMessage(), Status.DEBUG);
Logger.getLogger(CommonMethods.class.getName()).log(Level.SEVERE, null, e);
throw new ActionException(e);
}
}

Expand All @@ -50,6 +52,7 @@ public void StoreElementCount() {
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, ex);
Report.updateTestLog(Action, "Error Storing Element count:" + "\n" + ex.getMessage(), Status.DEBUG);
throw new ActionException(ex);
}
}

Expand All @@ -61,6 +64,7 @@ public void Highlight() {
} catch(Exception e) {
Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, e);
Report.updateTestLog("Could not perfom ["+Action+"] action", "Error: " + e.getMessage(),Status.FAIL);
throw new ActionException(e);
}
}
}
Loading

0 comments on commit 4dc7654

Please sign in to comment.