Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:qmetry/qaf.git
Browse files Browse the repository at this point in the history
  • Loading branch information
cjayswal committed Feb 4, 2024
2 parents f93fbd9 + 904364e commit fd58308
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 107 deletions.
24 changes: 17 additions & 7 deletions ivy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ SOFTWARE.
</dependency>

<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency org="com.google.guava" name="guava" rev="31.1-jre" conf="compile->default">
<dependency org="com.google.guava" name="guava" rev="32.1.2-jre" conf="compile->default">
<artifact name="guava" type="jar"></artifact>
</dependency>

Expand All @@ -113,34 +113,44 @@ SOFTWARE.

<!-- min rev 3.0.0 -->
<dependency org="org.seleniumhq.selenium" name="selenium-remote-driver"
rev="3.6.0" conf="compile->default"/>
rev="4.0.0" conf="compile->default"/>
<dependency org="org.seleniumhq.selenium" name="selenium-java"
rev="3.6.0" conf="compile->default">
rev="4.0.0" conf="compile->default">
<exclude org="com.codeborne"/>
</dependency>
<!-- -->
<dependency org="org.seleniumhq.selenium" name="selenium-leg-rc" rev="3.6.0">
<dependency org="org.seleniumhq.selenium" name="selenium-leg-rc" rev="4.0.0">
<exclude org="org.testng"/>
</dependency>

<dependency org="org.codehaus.groovy" name="groovy-all"
rev="2.1.9" conf="provided->default" />
<dependency org="info.cukes" name="cucumber-java" rev="1.2.4" conf="provided->default"/>

<dependency org="org.json" name="json" rev="20180813" conf="compile->default"/>
<dependency org="org.json" name="json" rev="20231013" conf="compile->default"/>
<dependency org="javax.mail" name="mail" rev="1.4.7"/>

<!-- Java EXpression Language (jexl) - implementation of dynamic and scripting features as alternative arrangements for script engine JEP-372 JDK-8236933 -->
<dependency org="org.apache.commons" name="commons-jexl3" rev="3.2.1" conf="compile->default"/>

<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager
<dependency org="org.slf4j" name="slf4j-log4j12" rev="1.7.30" conf="compile->default"/> -->
<dependency org="io.github.bonigarcia" name="webdrivermanager" rev="4.4.3" conf="compile->default"/>
<dependency org="org.slf4j" name="slf4j-log4j12" rev="1.7.30" conf="compile->default"/> -->
<dependency org="io.github.bonigarcia" name="webdrivermanager" rev="latest.integration" conf="compile->default"/>

<!-- repo-editor -->
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents.core5/httpcore5 -->
<dependency org="org.apache.httpcomponents.core5" name="httpcore5" rev="5.2.1" conf="compile->default"/>
<!-- emailable report -->
<!-- https://mvnrepository.com/artifact/com.sun.mail/jakarta.mail -->
<dependency org="com.sun.mail" name="jakarta.mail" rev="2.0.1" conf="compile->default"/>

<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
<dependency org="org.apache.logging.log4j" name="log4j-api" rev="2.20.0" />

<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-compress -->
<dependency org="org.apache.commons" name="commons-compress" rev="1.25.0" conf="compile->default"/>


<!-- https://github.com/SeleniumHQ/selenium/issues/3118 -->
<exclude org="com.codeborne"/>

Expand Down
7 changes: 3 additions & 4 deletions src/com/qmetry/qaf/automation/core/QAFTestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.Map;
import java.util.concurrent.TimeUnit;

import com.qmetry.qaf.automation.util.StringUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.impl.LogFactoryImpl;
import org.openqa.selenium.WebDriverException;
Expand Down Expand Up @@ -454,11 +453,11 @@ protected void setReportDir(String reportDir) {
this.reportDir = reportDir;
}

@Override
//@Override
protected void finalize() throws Throwable {
logger.debug("Unloading TestBase, cleaning up...");
tearDown();
super.finalize();
//super.finalize();
}

private void init() {
Expand Down Expand Up @@ -537,7 +536,7 @@ private String base64ImageToFile(String base64Image) {
}

private String[] initStbArgs(String... args) {
args = STBArgs.browser_str.setIfEmpty(getBrowser(), args);
args = STBArgs.browser_str.setIfEmpty(getDriverName(), args);
return STBArgs.browser_str.setIfEmpty(
ApplicationProperties.DRIVER_NAME.getStringVal(STBArgs.browser_str.defaultVal),
STBArgs.base_url.setIfEmpty(
Expand Down
29 changes: 14 additions & 15 deletions src/com/qmetry/qaf/automation/ui/UiDriverFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerOptions;
import org.openqa.selenium.opera.OperaOptions;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.safari.SafariOptions;

Expand Down Expand Up @@ -114,7 +112,7 @@ public void tearDown(UiDriver driver) {
* @param driverName
* @return
*/
public static DesiredCapabilities getDesiredCapabilities(String driverName) {
public static Capabilities getDesiredCapabilities(String driverName) {
return Browsers.getBrowser(driverName).getDesiredCapabilities();
}

Expand Down Expand Up @@ -238,13 +236,15 @@ public static void loadDriverResouces(String driverName) {
}

private static WebDriver getDriverObj(Class<? extends WebDriver> of, Capabilities capabilities, String urlStr) {
Class<? extends Capabilities> capParamType = capabilities instanceof DesiredCapabilities? Capabilities.class:capabilities.getClass();

try {
//give it first try
Constructor<? extends WebDriver> constructor = of.getConstructor(URL.class, Capabilities.class);
Constructor<? extends WebDriver> constructor = of.getConstructor(URL.class, capParamType);
return constructor.newInstance(new URL(urlStr), capabilities);
} catch (Exception ex) {
try {
Constructor<? extends WebDriver> constructor = of.getConstructor(Capabilities.class);
Constructor<? extends WebDriver> constructor = of.getConstructor(capParamType);
return constructor.newInstance(capabilities);
} catch (Exception e) {
if (e.getCause() != null && e.getCause() instanceof WebDriverException) {
Expand All @@ -255,7 +255,7 @@ private static WebDriver getDriverObj(Class<? extends WebDriver> of, Capabilitie
} catch (Exception e1) {
try {
//give it another try
Constructor<? extends WebDriver> constructor = of.getConstructor(URL.class, Capabilities.class);
Constructor<? extends WebDriver> constructor = of.getConstructor(URL.class, capParamType);

return constructor.newInstance(new URL(urlStr), capabilities);
} catch (InvocationTargetException e2) {
Expand All @@ -282,9 +282,7 @@ private enum Browsers {
edge(new EdgeOptions(), EdgeDriver.class),

firefox(new FirefoxOptions(), FirefoxDriver.class), iexplorer(new InternetExplorerOptions(),
InternetExplorerDriver.class), chrome(new ChromeOptions(), ChromeDriver.class), opera(
new OperaOptions(),
"com.opera.core.systems.OperaDriver"), android(new DesiredCapabilities("android", "", Platform.ANDROID),
InternetExplorerDriver.class), chrome(new ChromeOptions(), ChromeDriver.class), android(new DesiredCapabilities("android", "", Platform.ANDROID),
"org.openqa.selenium.android.AndroidDriver"), iphone(
new DesiredCapabilities("iPhone", "", Platform.MAC),
"org.openqa.selenium.iphone.IPhoneDriver"), ipad(
Expand All @@ -307,15 +305,16 @@ private enum Browsers {
*/
other(new DesiredCapabilities());

private DesiredCapabilities desiredCapabilities;
private Capabilities desiredCapabilities;

private Class<? extends WebDriver> driverCls = null;
private String browserName = name();

private Browsers(Capabilities desiredCapabilities) {
this.desiredCapabilities = new DesiredCapabilities(desiredCapabilities.asMap());
this.desiredCapabilities.setCapability(CapabilityType.SUPPORTS_JAVASCRIPT,true);
this.desiredCapabilities.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
this.desiredCapabilities = desiredCapabilities;
//new DesiredCapabilities(desiredCapabilities.asMap());
//this.desiredCapabilities.setCapability(CapabilityType.SUPPORTS_JAVASCRIPT,true);
//this.desiredCapabilities.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
//this.desiredCapabilities.setCapability(CapabilityType.SUPPORTS_FINDING_BY_CSS, true);

}
Expand Down Expand Up @@ -343,7 +342,7 @@ private Browsers(Capabilities desiredCapabilities, Class<? extends WebDriver> dr
}

@SuppressWarnings("unchecked")
private DesiredCapabilities getDesiredCapabilities() {
private Capabilities getDesiredCapabilities() {
Map<String, Object> capabilities = new HashMap<String, Object>(desiredCapabilities.asMap());
Gson gson = new GsonBuilder().create();

Expand Down Expand Up @@ -392,7 +391,7 @@ private DesiredCapabilities getDesiredCapabilities() {
capabilities.put(key, ConfigurationManager.getBundle().getSubstitutor().replace(value));
}
}
return new DesiredCapabilities(capabilities);
return desiredCapabilities.merge(new DesiredCapabilities(capabilities));//new DesiredCapabilities(capabilities);
}

private static Browsers getBrowser(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
******************************************************************************/
package com.qmetry.qaf.automation.ui.selenium.webdriver;

import org.openqa.selenium.internal.WrapsDriver;
import org.openqa.selenium.WrapsDriver;

import com.qmetry.qaf.automation.ui.selenium.IsSeleniumImpl;
import com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebDriver;
import com.thoughtworks.selenium.CommandProcessor;

/**
* com.qmetry.qaf.automation.ui.selenium.ISWebDriverBackedSelenium.java
*
* @deprecated
* @author chirag
*/
public class QAFWebDriverBackedSelenium extends IsSeleniumImpl implements WrapsDriver {
Expand All @@ -47,7 +47,7 @@ public QAFWebDriverBackedSelenium(QAFExtendedWebDriver baseDriver, String baseUr
/**
* @param commandProcessor
*/
public QAFWebDriverBackedSelenium(com.thoughtworks.selenium.CommandProcessor commandProcessor) {
public QAFWebDriverBackedSelenium(CommandProcessor commandProcessor) {
super(commandProcessor);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public class ElementMetaDataListener extends QAFWebElementCommandAdapter {
public static final String TYPE = "type";

public static final List<String> COMMANDS_REQUIRES_SCROLL = Arrays.asList(DriverCommand.CLICK_ELEMENT,
DriverCommand.SEND_KEYS_TO_ELEMENT, DriverCommand.CLICK, DriverCommand.CLICK_ELEMENT,
DriverCommand.DOUBLE_CLICK, DriverCommand.MOVE_TO, DriverCommand.MOUSE_DOWN, DriverCommand.MOUSE_UP,
DriverCommand.SEND_KEYS_TO_ELEMENT,
//DriverCommand.ACTIONS,
DriverCommand.ELEMENT_SCREENSHOT);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
******************************************************************************/
package com.qmetry.qaf.automation.ui.webdriver;

import static org.openqa.selenium.remote.CapabilityType.SUPPORTS_JAVASCRIPT;
//import static org.openqa.selenium.remote.CapabilityType.SUPPORTS_JAVASCRIPT;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
Expand All @@ -33,8 +33,8 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
//import java.util.stream.Collectors;
//import java.util.stream.Stream;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand All @@ -43,27 +43,26 @@
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.Rotatable;
//import org.openqa.selenium.Rotatable;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.TouchScreen;
//import org.openqa.selenium.interactions.TouchScreen;
import org.openqa.selenium.remote.Augmenter;
import org.openqa.selenium.remote.CapabilityType;
//import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.CommandExecutor;
import org.openqa.selenium.remote.CommandPayload;
import org.openqa.selenium.remote.DriverCommand;
import org.openqa.selenium.remote.RemoteTouchScreen;
//import org.openqa.selenium.remote.RemoteTouchScreen;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.Response;
import org.openqa.selenium.remote.ScreenshotException;
import org.openqa.selenium.remote.internal.WebElementToJsonConverter;
//import org.openqa.selenium.remote.internal.WebElementToJsonConverter;
import org.openqa.selenium.support.ui.ExpectedConditions;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
//import com.google.common.collect.Lists;
import com.qmetry.qaf.automation.core.ConfigurationManager;
import com.qmetry.qaf.automation.core.MessageTypes;
import com.qmetry.qaf.automation.core.QAFListener;
Expand Down Expand Up @@ -305,7 +304,7 @@ protected Response executeWitoutLog(String driverCommand, Map<String, ?> paramet
*
* @see org.openqa.selenium.TakesScreenshot#getScreenshotAs(org.openqa.selenium
* .OutputType)
*/
@Override
public <X> X getScreenshotAs(OutputType<X> target) throws WebDriverException {
Object takeScreenshot = getCapabilities().getCapability(CapabilityType.TAKES_SCREENSHOT);
Expand All @@ -314,7 +313,7 @@ public <X> X getScreenshotAs(OutputType<X> target) throws WebDriverException {
return target.convertFromBase64Png(base64Str);
}
return null;
}
}*/

public <T> T extractScreenShot(WebDriverException e, OutputType<T> target) {
if (e.getCause() instanceof ScreenshotException) {
Expand Down Expand Up @@ -482,10 +481,10 @@ private void injectSizzle() {
+ "headID.appendChild(newScript);");
}

@Override
public TouchScreen getTouchScreen() {
return new RemoteTouchScreen(getExecuteMethod());
}
// @Override
// public TouchScreen getTouchScreen() {
// return new RemoteTouchScreen(getExecuteMethod());
// }

@Override
public String takeScreenShot() {
Expand Down Expand Up @@ -635,12 +634,13 @@ public List<WebElement> findElementsByCustomStretegy(String stetegy, String loc)
return (List<WebElement>) execute(DriverCommand.FIND_ELEMENTS, ImmutableMap.of("using",stetegy,"value",loc)).getValue();
}

@Override
//@Override
public void stop() {
quit();
}

@Override
//Fixed null pointer exception with 4.0.0-beta-1 https://github.com/SeleniumHQ/selenium/commit/d16ecd2a32a1270b9b31f69358ee964e572b7d57
/*@Override
public Object executeScript(String script, Object... args) {
if (!isJavascriptEnabled()) {
throw new UnsupportedOperationException(
Expand Down Expand Up @@ -677,6 +677,6 @@ public Object executeAsyncScript(String script, Object... args) {
boolean isJavascriptEnabled() {
return ((null == getCapabilities().getCapability(SUPPORTS_JAVASCRIPT))
|| getCapabilities().is(SUPPORTS_JAVASCRIPT));
}
}*/

}
36 changes: 18 additions & 18 deletions src/com/qmetry/qaf/automation/ui/webdriver/QAFWebDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.interactions.HasInputDevices;
import org.openqa.selenium.interactions.Keyboard;
import org.openqa.selenium.interactions.Mouse;
import org.openqa.selenium.interactions.TouchScreen;
import org.openqa.selenium.internal.FindsByClassName;
import org.openqa.selenium.internal.FindsByCssSelector;
import org.openqa.selenium.internal.FindsById;
import org.openqa.selenium.internal.FindsByLinkText;
import org.openqa.selenium.internal.FindsByName;
import org.openqa.selenium.internal.FindsByTagName;
import org.openqa.selenium.internal.FindsByXPath;
//import org.openqa.selenium.interactions.HasInputDevices;
//import org.openqa.selenium.interactions.Keyboard;
//import org.openqa.selenium.interactions.Mouse;
//import org.openqa.selenium.interactions.TouchScreen;
//import org.openqa.selenium.internal.FindsByClassName;
//import org.openqa.selenium.internal.FindsByCssSelector;
//import org.openqa.selenium.internal.FindsById;
//import org.openqa.selenium.internal.FindsByLinkText;
//import org.openqa.selenium.internal.FindsByName;
//import org.openqa.selenium.internal.FindsByTagName;
//import org.openqa.selenium.internal.FindsByXPath;

import com.qmetry.qaf.automation.ui.JsToolkit;
import com.qmetry.qaf.automation.ui.UiDriver;
import com.qmetry.qaf.automation.util.StringMatcher;

public interface QAFWebDriver extends UiDriver, WebDriver, TakesScreenshot, JavascriptExecutor, FindsByCustomStretegy,
HasInputDevices, HasCapabilities {
public interface QAFWebDriver extends UiDriver, WebDriver, TakesScreenshot, JavascriptExecutor, FindsByCustomStretegy, HasCapabilities{
// HasInputDevices, HasCapabilities {

public QAFWebElement findElement(By by);

Expand All @@ -55,11 +55,11 @@ public interface QAFWebDriver extends UiDriver, WebDriver, TakesScreenshot, Java

public List<QAFWebElement> findElements(String locator);

public Mouse getMouse();

public Keyboard getKeyboard();

public TouchScreen getTouchScreen();
// public Mouse getMouse();
//
// public Keyboard getKeyboard();
//
// public TouchScreen getTouchScreen();


public void waitForAjax(JsToolkit toolkit, long... timeout);
Expand Down
Loading

0 comments on commit fd58308

Please sign in to comment.