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
7 changes: 5 additions & 2 deletions .github/workflows/end_to_end_tests_internal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ jobs:
java-version: "${{ env.java_version }}"
distribution: corretto

- name: Build project (Stagenet)
run: chmod +x ./gradlew && ./gradlew app:assembleStagenetDebug --stacktrace
- name: Build preview
run: ./gradlew app:assemblePreviewDebug --stacktrace

# Log APK Path and store it as an environment variable
- name: Log APK Path
Expand Down Expand Up @@ -105,6 +105,9 @@ jobs:
appium --log-level debug & # Start Appium in the background
sleep 10 # Wait for Appium to initialize

- name: Appium Driver List
run: appium driver list

- name: Run tests
uses: reactivecircus/android-emulator-runner@v2
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package cryptox_AndroidTest;

import config.appiumconnection;
import io.appium.java_client.MobileElement;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.*;
import java.net.MalformedURLException;
import static config.appiumconnection.*;
import static config.systemInfo.getDeviceDimensions;
import static pages.generalMethods.*;

import config.configLoader;

public class baseClass {
Expand All @@ -17,7 +24,7 @@ public class baseClass {
public static String appURL;
public static String Device;
public static String testnetPackageName = "com.pioneeringtechventures.wallet.testnet";
public static String stagePackageName = "com.pioneeringtechventures.wallet.stagenet";
public static String stagePackageName = "com.pioneeringtechventures.wallet.testnet"; //"com.pioneeringtechventures.wallet.stagenet";
public static String activityName = "com.concordium.wallet.ui.MainActivity";
public static String PackageName = stagePackageName;

Expand All @@ -39,18 +46,66 @@ public void setup() throws MalformedURLException, InterruptedException {

openAppiumSession(Device, PackageName, activityName);
getDeviceDimensions();
getCustomNetwork();
}

@AfterTest
public void tearDown(){
//// driver.removeApp(PackageName); // This will remove the app from the device
//}
if(!localExecution){
driver.removeApp(PackageName); // This will remove the app from the device
}
else {
// if(!localExecution){
// driver.removeApp(PackageName); // This will remove the app from the device
// }
// else {
driver.quit(); // This will close the appium driver.
// }
}

public void getCustomNetwork() throws InterruptedException {
driver.activateApp(PackageName);
if (isElementPresent("toolbar_networks_btn", 5)) {
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);
WebDriverWait wait = new WebDriverWait(driver, 20);
MobileElement saveBtn = (MobileElement) wait.until(ExpectedConditions.elementToBeClickable(By.id("save_button")));
saveBtn.click();
saveBtn.click();
Thread.sleep(3000);
Assert.assertTrue(verifyElementByXpath("//android.widget.TextView[@resource-id=\"com.pioneeringtechventures.wallet.testnet:id/name_text_view\" and @text=\"Stagenet\"]", 20));
} else {
System.out.println("toolbar_networks_btn not visible — skipping custom network setup.");
}
}
public boolean turnOnToggle(String elementId, int timeoutInSeconds) {
try {
MobileElement toggle = (MobileElement) waitForElement(By.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 boolean isElementPresent(String locatorKey, int timeout) {
try {
WebDriverWait wait = new WebDriverWait(driver, timeout);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.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;
}
}

}

39 changes: 37 additions & 2 deletions cryptox-android-autotests/src/test/java/pages/generalMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public static boolean verifyElementByXpath(String elementID, Integer timeout) {
return true;
} else {

System.out.println("unable to verify Element" + elementID);
log.error("unable to verify Element" + elementID);
return false;
}

Expand Down Expand Up @@ -295,7 +295,7 @@ public static boolean clickOnElementByXpath(String elementID, Integer timeout) {
return true;
} else {

System.out.println("unable to find Element" + elementID);
log.error("unable to find Element" + elementID);

return false;
}
Expand Down Expand Up @@ -343,6 +343,41 @@ public static boolean SendTextToField(String elementID, String Text, Integer tim
return false;
}

public static boolean SendTextToFieldByXpath(String elementID, String Text, Integer timeout)

{
try
{
By elementIDs = By.xpath(elementID);

MobileElement elementToLookFor = waitForElement(elementIDs,timeout);

assert elementToLookFor != null;
if (elementToLookFor.isDisplayed()){
elementToLookFor.clear();
elementToLookFor.click();
elementToLookFor.sendKeys(Text);
return true;
}


else {

System.out.println("unable to find Element" + elementID );

return false;
}

} catch (Exception exp) {
log.error(String.valueOf(exp.getCause()));
System.out.println(exp.getMessage());
log.error(String.valueOf(exp.fillInStackTrace()));
}

return false;
}


public static boolean SendTextToFieldByClassName(String elementID, String Text, Integer timeout)

{
Expand Down
6 changes: 3 additions & 3 deletions cryptox-android-autotests/testng.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<test name="CryptoX - Android">
<classes>
<class name="cryptox_AndroidTest.baseClass"/>
<class name="cryptox_AndroidTest.RecoverAccounts.RecoverAccountThroughFileWallet"/>
<class name="cryptox_AndroidTest.Settings.settingsCases"/>
<!-- <class name="cryptox_AndroidTest.RecoverAccounts.RecoverAccountThroughFileWallet"/>-->
<!-- <class name="cryptox_AndroidTest.Settings.settingsCases"/>-->
<class name="cryptox_AndroidTest.RecoverAccounts.recoverAccountThroughSeedPhrase"/>
<class name="cryptox_AndroidTest.Validation.createValidatorWithNoDelegation"/>
<class name="cryptox_AndroidTest.Validation.validatorWithOpenForDelegation"/>
Expand All @@ -18,7 +18,7 @@
<class name="cryptox_AndroidTest.Settings.removeAccount"/>
<class name="cryptox_AndroidTest.RecoverAccounts.RecoverAccountCases"/>
<class name="cryptox_AndroidTest.AccountCreation.AccountCreation"/>
<class name="cryptox_AndroidTest.DualWallet.DualWalletCases"/>
<!-- <class name="cryptox_AndroidTest.DualWallet.DualWalletCases"/>-->
</classes>
</test>
</suite>
Loading