Skip to content

Commit

Permalink
Final commit for release 1.23.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ksitwala-perfecto committed Jun 9, 2021
1 parent 60abe18 commit 8ebfbe4
Show file tree
Hide file tree
Showing 7 changed files with 828 additions and 806 deletions.
66 changes: 38 additions & 28 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<reportium-sdk.version>2.3</reportium-sdk.version>
<selenium.version>3.141.59</selenium.version>
<testng.version>7.3.0</testng.version>
<testng.version>6.10</testng.version>
<cukes.version>1.2.5</cukes.version>
<org.json.version>20160810</org.json.version>
<perfectomobile.version>18.3.0.3</perfectomobile.version>
<intellij.perfectomobile.version>18.4.0.0 </intellij.perfectomobile.version>
<qaf.version>2.1.15</qaf.version>
<qafsupport.version>2.1.15</qafsupport.version>
<qaf.version>3.0.0</qaf.version>
<qafsupport.version>3.0.0</qafsupport.version>
<appium.client.version>7.3.0</appium.client.version>
</properties>

Expand Down Expand Up @@ -127,6 +127,7 @@
<artifactId>http-client</artifactId>
<version>${perfectomobile.version}</version>
</dependency>

<dependency>
<groupId>com.qmetry</groupId>
<artifactId>qaf</artifactId>
Expand All @@ -136,24 +137,26 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
</exclusion>
<!-- <exclusion> -->
<!-- <groupId>org.seleniumhq.selenium</groupId> -->
<!-- <artifactId>selenium-remote-driver</artifactId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <groupId>org.seleniumhq.selenium</groupId> -->
<!-- <artifactId>selenium-api</artifactId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <groupId>org.seleniumhq.selenium</groupId> -->
<!-- <artifactId>selenium-java</artifactId> -->
<!-- </exclusion> -->
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.qmetry</groupId>
<artifactId>qaf-support</artifactId>
<version>${qafsupport.version}</version>
<exclusions>
<exclusion>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
</exclusion>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.perfectomobile</groupId>
Expand All @@ -180,6 +183,12 @@
<groupId>com.perfecto.reporting-sdk</groupId>
<artifactId>reportium-testng</artifactId>
<version>${reportium-sdk.version}</version>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>dom4j</groupId>
Expand Down Expand Up @@ -212,26 +221,27 @@
<version>29.0-jre</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.7.0</version>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.7.0</version>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.10.7</version>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.10.7</version>
</dependency>

</dependencies>
</project>
31 changes: 0 additions & 31 deletions src/main/java/com/qmetry/qaf/automation/ui/UiDriverFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,39 +184,8 @@ private static Collection<QAFWebDriverCommandListener> getDriverListeners() {
LinkedHashSet<QAFWebDriverCommandListener> listners = new LinkedHashSet<QAFWebDriverCommandListener>();
String[] clistners = ConfigurationManager.getBundle()
.getStringArray(ApplicationProperties.WEBDRIVER_COMMAND_LISTENERS.key);
// Condition for shared session ID skip DriverInit Check
String valPerfectoCap = ConfigurationManager.getBundle().getString("perfecto.capabilities.deviceSessionId", "");
String valDriverCap = ConfigurationManager.getBundle().getString("driver.capabilities.deviceSessionId", "");
boolean skipDriverInitList = false;
Iterator<String> it = ConfigurationManager.getBundle().getKeys();
System.out.println("Loading listeners");
while (it.hasNext()) {
try {
System.out.println(it.next());
String key = it.next();
if (key.contains("capabilities.deviceSessionId") || key.contains("additional.capabilities")) {
if (ConfigurationManager.getBundle().getString(key).contains("-")
|| ConfigurationManager.getBundle().getString(key).contains("'useVirtualDevice':true")) {
System.out.println("Executing on VD or Shared Session, therefore skipping DriverInitListener");
skipDriverInitList = true;
break;
}
}
} catch (Exception e) {
// Catch exception for when the value inside the key is not a string
}

}
// Condition for virtual device skip DriverInit Check
String capPerfectoVD = ConfigurationManager.getBundle().getString("perfecto.additional.capabilities", "");
String capDriverVD = ConfigurationManager.getBundle().getString("driver.additional.capabilities", "");

for (String listenr : clistners) {
if (skipDriverInitList
&& listenr.equals(DriverInitListener.class.getName())) {
System.out.println("!!!!!Not running Driver Init listener check because a shared session or a virtual device session was detected.!!!!!");
continue;
}
try {
QAFWebDriverCommandListener cls = (QAFWebDriverCommandListener) Class.forName(listenr).newInstance();
listners.add(cls);
Expand Down
60 changes: 17 additions & 43 deletions src/main/java/com/quantum/listeners/DriverInitListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private static boolean isDeviceCombinationValid(String url) {
}
}

@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "deprecation", "rawtypes" })
public static boolean waitForDeviceAvailable(Device deviceInformation, Map<String, String> credentials)
throws TimeoutException {

Expand Down Expand Up @@ -233,33 +233,22 @@ public Boolean apply(String apiUrl) {

}

@SuppressWarnings("unchecked")
public void beforeInitialize(Capabilities desiredCapabilities) {

// String valPerfectoCap = ConfigurationManager.getBundle().getString("perfecto.capabilities.deviceSessionId", "");
// String valDriverCap = ConfigurationManager.getBundle().getString("driver.capabilities.deviceSessionId", "");
// boolean skipDriverInitList = false;
// Iterator<String> it = ConfigurationManager.getBundle().getKeys();
// System.out.println("Loading listeners");
// while (it.hasNext()) {
// System.out.println(it.next());
// String key = it.next();
// if (key.contains("capabilities.deviceSessionId") || key.contains("additional.capabilities")) {
// if (ConfigurationManager.getBundle().getString(key).contains("-")
// || ConfigurationManager.getBundle().getString(key).contains("'useVirtualDevice':true")) {
// System.out.println("Executing on VD or Shared Session, therefore skipping DriverInitListener");
// skipDriverInitList = true;
// }
//
// }
// }
// Condition for virtual device skip DriverInit Check
// String capPerfectoVD = ConfigurationManager.getBundle().getString("perfecto.additional.capabilities", "");
// String capDriverVD = ConfigurationManager.getBundle().getString("driver.additional.capabilities", "");
//
// for (String listenr : clistners) {
// if ((valPerfectoCap.contains("-") || valDriverCap.contains("-"))

// if (!skipDriverInitList) {
boolean skipDriverInitList = false;
Iterator<String> it = ConfigurationManager.getBundle().getKeys();
while (it.hasNext()) {
String key = it.next();
if (key.contains("capabilities.deviceSessionId") || key.contains("additional.capabilities")) {
System.out.println("Value - " + ConfigurationManager.getBundle().getString(key));
if (ConfigurationManager.getBundle().getString(key).contains("-")
|| ConfigurationManager.getBundle().getString(key).contains("'useVirtualDevice':true")) {
System.out.println("Executing on VD or Shared Session, therefore skipping DriverInitListener");
skipDriverInitList = true;
}
}
}
if (!skipDriverInitList) {
Device device = new Device();
Map<String, ?> capabilities = desiredCapabilities.asMap();

Expand Down Expand Up @@ -288,12 +277,7 @@ public void beforeInitialize(Capabilities desiredCapabilities) {
if (capabilities.get("osVersion") != null) {
device.addAttribute("osVersion", capabilities.get("osVersion").toString());
}

// System.out.println(desiredCapabilities);

// waitForDeviceAvailable(device,credentials);
if (!ConfigurationManager.getBundle().getBoolean("device_not_available", false)) {

try {
boolean deviceAvailableFlag = waitForDeviceAvailable(device, credentials);
System.out.println("Device availability flag - " + deviceAvailableFlag);
Expand All @@ -318,40 +302,30 @@ public void beforeInitialize(Capabilities desiredCapabilities) {

}
} catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
throw e;
}
} else {
throw new SkipException("Device not available");
}

// }

}
}

public static class Device {

private Map<String, String> deviceAttributes;

public Device() {
this.deviceAttributes = new HashMap<>();
}

void addAttribute(String attributeName, String attributeValue) {
deviceAttributes.put(attributeName, attributeValue);
}

public Map<String, String> getDeviceAttributes() {
return this.deviceAttributes;
}

@Override
public String toString() {

return deviceAttributes.toString();
}

}
}
25 changes: 20 additions & 5 deletions src/main/java/com/quantum/listeners/QuantumReportiumListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import com.qmetry.qaf.automation.step.QAFTestStepListener;
import com.qmetry.qaf.automation.step.StepExecutionTracker;
import com.qmetry.qaf.automation.step.TestStep;
import com.qmetry.qaf.automation.step.client.Scenario;
import com.qmetry.qaf.automation.step.client.TestNGScenario;
import com.qmetry.qaf.automation.step.client.text.BDDDefinitionHelper.ParamType;
import com.qmetry.qaf.automation.ui.WebDriverTestCase;
Expand Down Expand Up @@ -441,7 +442,7 @@ private void tearIt(ITestResult testResult) {
.contains("com.qmetry.qaf.automation.step.client.excel.ExcelTestFactory")
|| testResult.getTestContext().getCurrentXmlTest().getXmlClasses().get(0).getName()
.contains("com.qmetry.qaf.automation.step.client.csv.KwdTestFactory")
|| resetDriver()
|| resetDriver(testResult)

) {
Object testInstance = testResult.getInstance();
Expand Down Expand Up @@ -714,14 +715,28 @@ private String getProcessStepDescription(TestStep step) {
return description;
}

private boolean resetDriver() {
private boolean resetDriver(ITestResult result) {
String driverResetTimerFlag = ConfigurationManager.getBundle().getString("perfecto.driver.restart.timer.flag",
"false");
int driverResetTimerValue = ConfigurationManager.getBundle().getInt("perfecto.driver.restart.timer.flag", 3600);
if (driverResetTimerFlag.equalsIgnoreCase("true")) {
int driverResetTimerValue = ConfigurationManager.getBundle().getInt("perfecto.driver.restart.timer.value",
3600);

boolean driverResetTag = false;
Scenario sc = (Scenario) result.getInstance();
String[] m_groups = sc.getM_groups();
for (String tag : m_groups) {
if (tag.equalsIgnoreCase("@RestartDriverAfterTimeout")) {
System.out.println("Driver Reset tag found!");
driverResetTag = true;
}
}

if (driverResetTimerFlag.equalsIgnoreCase("true") || driverResetTag) {
long currentTime = System.currentTimeMillis();
long driverStartTime = ConfigurationManager.getBundle().getLong(PerfectoDriverListener.DRIVER_START_TIMER);
if ((currentTime - driverStartTime) / 1000 > driverResetTimerValue) {

// Check the timer and the tag for restart @RestartDriverAfterTimeout
if ((currentTime - driverStartTime) / 1000 > driverResetTimerValue || driverResetTag) {
System.out.println("Closing the driver and restarting the driver");
return true;
}
Expand Down
Loading

0 comments on commit 8ebfbe4

Please sign in to comment.