Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,10 @@ public class appiumconnection {
public static final Logger log = LoggerFactory.getLogger(appiumconnection.class);


public static boolean openAppiumBSSession(String deviceName, String packageName, String activityName, String portNumber) throws MalformedURLException {
try {
startAppium(portNumber);
MutableCapabilities cap = new MutableCapabilities();
URL url = new URL("https://hub-cloud.browserstack.com/wd/hub");
driver = new AndroidDriver<>(url, cap);
log.info("Application Started");
return true;
} catch (Exception exp) {
log.error("Error starting Appium session: {}", exp.getMessage());
log.error("Stack Trace: ", exp);
}
return false;
}

public static boolean openAppiumSession(String deviceName, String packageName, String activityName) throws MalformedURLException {
try {
DesiredCapabilities cap = getDesiredCapabilities(deviceName, packageName, activityName);
URL url = new URL("http://127.0.0.1:4723/");
System.out.println("This is the URL " + url);
System.out.println("This is the APPURL " + appURL);
System.out.println("This is the device " + Device);
driver = new AndroidDriver<>(url, cap);
Expand Down Expand Up @@ -86,52 +70,6 @@ public static void grantNotificationPermission(String emulatorId, String appPac
}
}

public static boolean openDeviceFarmAppiumSession() throws MalformedURLException {
try {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android"); // Platform (can also be iOS)
capabilities.setCapability("deviceName", "DeviceName"); // You can specify a device or use a pool
capabilities.setCapability("app", "arn:aws:devicefarm:us-west-2:192549843005:upload:000d9278-b81b-4319-93c8-87a7bba8f00b/bad4d852-0300-4716-be4d-63ad5c330ea6"); // ARN of your uploaded app
capabilities.setCapability("automationName", "Appium");

// AWS Device Farm endpoint URL (ensure to use the correct region)
String deviceFarmAppiumUrl = "https://devicefarm.us-west-2.amazonaws.com/wd/hub"; // Update region if necessary

// Create the remote driver connection to AWS Device Farm's Appium server
driver = new AndroidDriver(new URL(deviceFarmAppiumUrl), capabilities);
return true;
} catch (Exception exp) {
log.error("Error starting Appium session: {}", exp.getMessage());
log.error("Stack Trace: ", exp);
}
return false;
}


public static boolean openLocalAppiumSession(String deviceName, String packageName, String activityName, String portNumber) throws MalformedURLException {
try {
startAppium(portNumber);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("deviceName", "Galaxy A51");
cap.setCapability("udid",deviceName );
cap.setCapability("platformName", "Android");
cap.setCapability("platformVersion", "12");
cap.setCapability("appPackage", packageName);
cap.setCapability("appActivity", activityName);
cap.setCapability("autoGrantPermissions", true);
//

cap.setCapability("automationName", "UiAutomator2");
URL url = new URL("http://127.0.0.1:" + portNumber);
driver = new AndroidDriver<>(url, cap);
System.out.println("Application Started");
return true;
} catch (Exception exp) {
log.error("Error starting Appium session: {}", exp.getMessage());
log.error("Stack Trace: ", exp);
}
return false;
}

// Method to wait for an element to be visible
public static MobileElement waitForElement(By locator, int timeoutInSeconds) {
Expand Down
31 changes: 0 additions & 31 deletions cryptox-android-autotests/src/test/java/config/configLoader.java

This file was deleted.

106 changes: 104 additions & 2 deletions cryptox-android-autotests/src/test/java/config/systemInfo.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
package config;

import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;

import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

import static config.appiumconnection.driver;
import static config.appiumconnection.log;
import static config.appiumconnection.*;
import static cryptox_AndroidTest.baseClass.PackageName;
import static org.openqa.selenium.By.id;
import static pages.generalMethods.*;

public class systemInfo {

Expand Down Expand Up @@ -56,4 +65,97 @@ public static String getCurrentActivity(){
log.info("Hello Hello Hello, This is current Activity{}", currentActivity);
return currentActivity;
}
public static void getCustomNetwork() throws InterruptedException {
driver.activateApp(PackageName);
if (isElementPresent("toolbar_networks_btn", 20)) {
clickOnElement("toolbar_networks_btn", 20);
turnOnToggle("dev_mode_switch", 20);
clickOnElement("add_button", 20);
SendTextToFieldByXpath(
"(//android.widget.EditText[@resource-id=\"com.pioneeringtechventures.wallet.testnet:id/edittext\"])[1]",
"Stagenet", 20);
SendTextToFieldByXpath(
"(//android.widget.EditText[@resource-id=\"com.pioneeringtechventures.wallet.testnet:id/edittext\"])[2]",
"https://wallet-proxy.stagenet.concordium.com/", 20);
SendTextToFieldByXpath(
"(//android.widget.EditText[@resource-id=\"com.pioneeringtechventures.wallet.testnet:id/edittext\"])[4]",
"https://stagenet.ccdscan.io/", 20);

System.out.println("Successfully entered custom network details.");
try {
if (driver.isKeyboardShown()) {
System.out.println("Keyboard is visible, dismissing via AndroidKey.BACK.");
((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.BACK));
System.out.println("Keyboard dismissed successfully.");
} else {
System.out.println("Keyboard was not visible, skipping dismiss.");
}
} catch (Exception e) {
System.out.println("Could not dismiss keyboard: " + e.getMessage());
}
if (isElementPresent("cancel_button", 20)) {
clickOnElement("cancel_button", 20);
System.out.println("Successfully click on keep editing button");
}
else {
System.out.println("unable to click on keep editing button");
}
WebDriverWait wait = new WebDriverWait(driver, 20);
MobileElement saveBtn = (MobileElement) wait.until(
ExpectedConditions.elementToBeClickable(id("save_button")));

int maxAttempts = 10;
int attempt = 0;
while (!driver.findElements(id("save_button")).isEmpty() && attempt < maxAttempts) {
saveBtn.click();
saveBtn.click();
System.out.println("Clicked save button, attempt " + (attempt + 1) + ", waiting for it to disappear...");
Thread.sleep(1000);
attempt++;
}

Assert.assertTrue(driver.findElements(id("save_button")).isEmpty(), "Save button did not disappear after " + maxAttempts + " attempts");
System.out.println("Save button is not visible");
boolean isSwitched = false;
for (int i = 0; i < 3; i++) {
if (verifyElementByXpath("//android.widget.TextView[@resource-id=\"com.pioneeringtechventures.wallet.testnet:id/name_text_view\" and @text=\"Stagenet\"]", 5)) {
isSwitched = true;
System.out.println("Successfully switched to the custom network setup.");
break;
} else {
System.out.println("Retry " + (i + 1) + ": Not switched yet...");
Thread.sleep(2000); // important wait before retry
}
}
Assert.assertTrue(isSwitched, "Failed to switch to Stagenet after retries");
}
}

public static boolean turnOnToggle(String elementId, int timeoutInSeconds) {
try {
MobileElement toggle = (MobileElement) waitForElement(id(elementId), timeoutInSeconds);
if (toggle.getAttribute("checked").equals("false")) {
toggle.click();
}
log.info("Successfully Toggled");
return true;
} catch (Exception e) {
e.printStackTrace();
log.error("Unable to perform Toggled");
return false;
}
}

public static boolean isElementPresent(String locatorKey, int timeout) {
try {
WebDriverWait wait = new WebDriverWait(driver, timeout);
wait.until(ExpectedConditions.visibilityOfElementLocated(id(locatorKey)));
log.info("Network button {} is visible. Proceeding with the flow of setting a customized network.", locatorKey);
return true;
} catch (Exception e) {
log.error("Network button {} is not visible. Proceeding with the normal flow without setting a customized network.", locatorKey);
return false;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import static config.appiumconnection.driver;
import static config.appiumconnection.log;
import static config.systemInfo.getCustomNetwork;
import static config.systemInfo.getSeedPhrase;
import static cryptox_AndroidTest.RecoverAccounts.RecoverAccountCases.continueButton;
import static cryptox_AndroidTest.RecoverAccounts.RecoverAccountThroughFileWallet.WALLET_FILE_NAME;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.net.MalformedURLException;

import static config.appiumconnection.*;
import static config.systemInfo.getCustomNetwork;
import static pages.accountRecovery.recoveryThroughPrivateKey.*;
import static pages.createPassCodeScreen.createPassCodeNow;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import static config.appiumconnection.driver;
import static config.appiumconnection.log;
import static config.systemInfo.getCustomNetwork;
import static config.systemInfo.getSeedPhrase;
import static cryptox_AndroidTest.RecoverAccounts.RecoverAccountCases.continueButton;
import static pages.accountRecovery.recoveryThroughPrivateKey.clickOnImportViaBackupFile;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
package cryptox_AndroidTest.Transactions;

import config.configLoader;
import org.openqa.selenium.WebElement;

import org.testng.Assert;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;
import java.net.MalformedURLException;
import static config.appiumconnection.driver;
import static config.appiumconnection.openAppiumSession;
import static cryptox_AndroidTest.RecoverAccounts.RecoverAccountCases.navigation_bar_item_large_label_view;
import static cryptox_AndroidTest.RecoverAccounts.RecoverAccountCases.newsTabButton;

import static cryptox_AndroidTest.baseClass.*;
import static pages.Transactions.requestCCDs.clickOnAccountWidget;
import static pages.accountRecovery.recoveryThroughPrivateKey.*;
import static pages.appOperations.commands.performScroll;

import static pages.appOperations.commands.swipe;
import static pages.generalMethods.*;
import static pages.login.loginCryptoX;
import static pages.verifyPIN.verifyPinAndPressOK;

public class CCDTransactions {
// config.configLoader configLoader = new configLoader("src/main/resources/setupData.properties");
// String RecoveryAccount = configLoader.getProperty("RecoveryAccountAddress");
// public String RecoveryAccount = "4Ek1LdFtdbkSwowStM73fMp6ZZd1RLTvQpRr1ZLJMVgPjUx4JT";




Expand Down

This file was deleted.

Loading
Loading