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
4 changes: 4 additions & 0 deletions src/main/java/com/crowdar/tella/constants/FilesConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ public class FilesConstants {
public static final String ADD_FOLDER = "id:fab_move_button";

public static final String NEW_FOLDER = "xpath://android.widget.TextView[@resource-id=\"org.hzontal.tella:id/fileNameTextView\" and @text=\"TellaFolder\"]";

public static final String SELECT_FOLDER_ICON = "xpath://android.widget.TextView[@resource-id=\"org.hzontal.tella:id/textTitle\" and @text=\"%s\"]";
public static final String ICON_FILE_AUDIO = "xpath://android.widget.FrameLayout[@resource-id=\"org.hzontal.tella:id/attachmentImgContainer\"]";
public static final String NEXT_BTN = "xpath://android.widget.TextView[@resource-id=\"org.hzontal.tella:id/next_btn\"]";
}
2 changes: 2 additions & 0 deletions src/main/java/com/crowdar/tella/constants/HomeConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ public class HomeConstants {

public static final String PICK_GOOGLE_ACCOUNT = "xpath:(//android.widget.LinearLayout[@resource-id=\"com.google.android.gms:id/container\"])[1]";
public static final String ALOW_GOOGLE_IN_TELLA = "xpath://android.widget.Button[@resource-id=\"com.google.android.gms:id/agree_and_share_button\"]";
public static final String SLIDE_DELETE = "id:org.hzontal.tella:id/panic_seek";
public static final String LBL_CONNECTIOS = "id:org.hzontal.tella:id/serversText";
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ public class SettingsConstants {
public static final String DELETE_SERVER_ICON = "id:delete_server_tooltip";
public static final String HELP_INFO_TEXTVIEW = "xpath://android.widget.TextView[@text=\"%s\"]";
public static final String REMAINING_UNLOCK_ATTEMPTS = "(//android.widget.Switch[@resource-id=\"org.hzontal.tella:id/mSwitch\"])[1]";


public static final String CHECKBOX_DELETE_FILE = "xpath://android.widget.CheckBox[@resource-id=\"org.hzontal.tella:id/delete_vault\"]";
public static final String CHECKBOX_DELETE_DRAFT_SUBMITTE_DFORMS = "xpath://android.widget.CheckBox[@resource-id=\"org.hzontal.tella:id/delete_vault\"]";
public static final String CHECKBOX_DELETE_SERVER_SETTING = "xpath://android.widget.CheckBox[@resource-id=\"org.hzontal.tella:id/delete_server_settings\"]";
public static final String GO_BACK_BUTTON = "xpath://android.widget.ImageButton[@content-desc=\"go back\"]";
public static final String VIEW_COUNTER_MESSAGE = "xpath://android.widget.TextView[@text=\"%s\"]";

}
27 changes: 27 additions & 0 deletions src/main/java/com/crowdar/tella/services/FilesService.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,5 +232,32 @@ public static void chooseFolder() {
GenericService.commonClick(FilesConstants.PICK_FOLDER);
}

/**
* Open Open a folder by passing the name
*
* @param nameFolder name of the folder to access
*/
public static void clicFolder(String nameFolder) {
MobileActionManager.waitClickable(FilesConstants.SELECT_FOLDER_ICON, nameFolder).click();
}

/**
* Validate that the all files folder is not empty.
* This is confirmed by audio icon.
*/
public static void validateIsNotEmptyFolderAllFile() {
clicFolder("All files");
Assert.assertTrue(MobileActionManager.waitVisibility(FilesConstants.ICON_FILE_AUDIO).isDisplayed());
}

/**
* Validate that the all files folder is empty.
* This is confirmed by the empty folder icon.
*/
public static void validateIsEmptyFolderAllFile() {
clicFolder("All files");
Assert.assertTrue(MobileActionManager.waitVisibility(FilesConstants.EMPTY_VIEW_MSG_CONTAINER).isDisplayed());
}

}

39 changes: 39 additions & 0 deletions src/main/java/com/crowdar/tella/services/GenericService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.crowdar.core.actions.MobileActionManager;
import com.crowdar.driver.DriverManager;
import com.crowdar.tella.constants.HomeConstants;
import com.crowdar.tella.constants.SettingsConstants;
import io.appium.java_client.MobileBy;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
Expand Down Expand Up @@ -197,6 +198,44 @@ public static void lockScreenWaitAndUnlock(int timeMinute) {
}
}

/**
* Verifies whether the Tella app is currently active in the foreground.
* <p>
* This method retrieves the current package name of the app in the foreground
* and checks if it matches the Tella package: {@code org.hzontal.tella}.
* </p>
*
* @return {@code true} if the Tella app is currently active in the foreground;
* {@code false} if the app is closed or running in the background.
*/
public static boolean verifyActiveAppTella() {
AndroidDriver<?> driver = (AndroidDriver<?>) GenericService.getDriver();
String currentPackage = driver.getCurrentPackage();

if (!"org.hzontal.tella".equals(currentPackage)) {
System.out.println("The app is closed or in the background.");
return true;
} else {
System.out.println("The app is active in the foreground.");
return true;

}
}

/**
* we reopen the application
*/
public static void openAppTella() {
if (MobileActionManager.isAndroid()) {
AndroidDriver<?> driver = (AndroidDriver<?>) GenericService.getDriver();
driver.activateApp("org.hzontal.tella");
}
}

public static void clicBackIcon() {
MobileActionManager.waitVisibility(SettingsConstants.GO_BACK_BUTTON).click();
}

}


Expand Down
83 changes: 78 additions & 5 deletions src/main/java/com/crowdar/tella/services/HomeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,95 @@
import com.crowdar.core.actions.MobileActionManager;
import com.crowdar.tella.constants.HomeConstants;
import com.crowdar.tella.constants.HomeConstantsIOS;

import io.appium.java_client.android.AndroidDriver;


import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.PointerInput;
import org.openqa.selenium.interactions.Sequence;

import org.testng.Assert;


import java.time.Duration;
import java.util.Arrays;


public class HomeService {

public static void isHomeLoaded() {
if (MobileActionManager.isAndroid()) {
MobileActionManager.waitVisibility(HomeConstants.HOME_BUTTON);
MobileActionManager.waitVisibility(HomeConstants.CAMERA_BUTTON);
MobileActionManager.waitVisibility(HomeConstants.MIC_BUTTON);
Assert.assertTrue(MobileActionManager.isVisible(HomeConstants.HOME_BUTTON), HomeConstants.VIEW_NOT_DISPLAYED_MESSAGE);
} else {
MobileActionManager.waitVisibility(HomeConstants.HOME_BUTTON);
MobileActionManager.waitVisibility(HomeConstants.CAMERA_BUTTON);
MobileActionManager.waitVisibility(HomeConstants.MIC_BUTTON);
Assert.assertTrue(MobileActionManager.isVisible(HomeConstants.HOME_BUTTON), HomeConstants.VIEW_NOT_DISPLAYED_MESSAGE);
} else {
MobileActionManager.waitVisibility(HomeConstantsIOS.HOME_BUTTON);
MobileActionManager.waitVisibility(HomeConstantsIOS.CAMERA_BUTTON);
MobileActionManager.waitVisibility(HomeConstantsIOS.MIC_BUTTON);
Assert.assertTrue(MobileActionManager.isVisible(HomeConstantsIOS.HOME_BUTTON), HomeConstantsIOS.VIEW_NOT_DISPLAYED_MESSAGE);
}
}

public static void verifySwipeDeleteButtonIsVisibleOnHomeScreen() {
if (MobileActionManager.isAndroid()) {
Assert.assertTrue(MobileActionManager.waitVisibility(HomeConstants.SLIDE_DELETE).isDisplayed());
}
}

/**
* Simula el movimiento del dedo para arrastrar un SeekBar hasta su posición final (100%).
*
* @throws org.openqa.selenium.NoSuchElementException si no se encuentra el SeekBar por ID.
*/
public static void moveFingerSeekBarToEnd() {
//Validamos que se encuentre y este visible
if (MobileActionManager.waitVisibility(HomeConstants.SLIDE_DELETE).isDisplayed()) {
AndroidDriver<?> driver = (AndroidDriver<?>) GenericService.getDriver();
//Aqui recuperamos parte de la cadena, pero obtener el Id del elemento
WebElement seekBar = MobileActionManager.getElement(HomeConstants.SLIDE_DELETE);
//driver.findElement(By.id(HomeConstants.SLIDE_DELETE.split(":")[1]));

int startX = seekBar.getLocation().getX();
int width = seekBar.getSize().getWidth();
int endX = startX + width - 10;

// Simula el movimiento del dedo al desplazar el SeekBar
PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");
Sequence drag = new Sequence(finger, 1);

int thumbX = 117; // Posición inicial del thumb (ajustado manualmente según el dispositivo)
int thumbY = 1850; // Altura del SeekBar en pantalla

// Presionar el thumb y mover hacia la derecha
drag.addAction(finger.createPointerMove(Duration.ZERO, PointerInput.Origin.viewport(), thumbX, thumbY));
drag.addAction(finger.createPointerDown(PointerInput.MouseButton.LEFT.asArg()));
drag.addAction(finger.createPointerMove(Duration.ofMillis(600), PointerInput.Origin.viewport(), endX, thumbY));
drag.addAction(finger.createPointerUp(PointerInput.MouseButton.LEFT.asArg()));
driver.perform(Arrays.asList(drag));
}
}

public static void isConnection() {
isHomeLoaded();
Assert.assertTrue(MobileActionManager.waitVisibility(HomeConstants.LBL_CONNECTIOS).isDisplayed());
}

public static void isNotConnection() {
isHomeLoaded();
try{
//Hacemos falla al proposito para indicar que el LBl de conexion ya no esta.
// Indicando que la conexion desaparecio
boolean flag = MobileActionManager.getElement(HomeConstants.LBL_CONNECTIOS).isDisplayed();
Assert.assertFalse(flag);
} catch (Exception e) {
System.out.println("The user is no longer connected to the Tella web server.");
}
}

public static void clicHomeButton() {
MobileActionManager.waitClickable(HomeConstants.HOME_BUTTON).click();
}

}
29 changes: 26 additions & 3 deletions src/main/java/com/crowdar/tella/services/ServersService.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ public static void okServerButton() {
}




public static void viewSettingServer(String server) {
if (MobileActionManager.isPresent(ServersConstants.URL_INPUT)) {
Assert.assertTrue(ActionManager.isPresent(ServersConstants.URL_INPUT));
Expand Down Expand Up @@ -161,7 +159,7 @@ public static void connectToTellaServer() {
MobileActionManager.setInput(ServersConstants.TELLA_PASS_INPUT, PropertyManager.getProperty("tellapass"));
MobileActionManager.click(ServersConstants.TEXT_SERVER_BUTTON, "Log in");
MobileActionManager.click(ServersConstants.SAVE_BUTTON);
MobileActionManager.click(ServersConstants.TEXT_SERVER_BUTTON, "OK");
MobileActionManager.click(ServersConstants.TEXT_SERVER_BUTTON, "GO TO REPORTS");
MobileActionManager.click(ServersConstants.BACK_BUTTON);
MobileActionManager.click(ServersConstants.BACK_BUTTON);
}
Expand Down Expand Up @@ -220,4 +218,29 @@ public static void googleDrive() {
}



public static void clicNextBtn() {
//Como el boton esta abajo de la pantalla, tenemos q escroliar hasta el final
// por ello utilizamos PointerInput para simular el movimiento del dedo
AndroidDriver<?> driver = (AndroidDriver<?>) GenericService.getDriver();

Dimension size = driver.manage().window().getSize();
int width = size.width / 2;

// Cambiar: empezar desde abajo y mover hacia arriba
int startY = (int) (size.height * 0.70); // más abajo
int endY = (int) (size.height * 0.30); // más arriba

PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");
Sequence swipe = new Sequence(finger, 1);
swipe.addAction(finger.createPointerMove(Duration.ZERO, PointerInput.Origin.viewport(), width, startY));
swipe.addAction(finger.createPointerDown(PointerInput.MouseButton.LEFT.asArg()));
swipe.addAction(finger.createPointerMove(Duration.ofMillis(300), PointerInput.Origin.viewport(), width, endY));
swipe.addAction(finger.createPointerUp(PointerInput.MouseButton.LEFT.asArg()));
driver.perform(List.of(swipe));

MobileActionManager.waitPresence(FilesConstants.NEXT_BTN).click();

}

}
37 changes: 37 additions & 0 deletions src/main/java/com/crowdar/tella/services/SettingsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static com.crowdar.driver.DriverManager.*;
import static org.bouncycastle.oer.its.ieee1609dot2.basetypes.Duration.seconds;
import static org.mozilla.javascript.Context.exit;

public class SettingsService {

Expand Down Expand Up @@ -292,4 +293,40 @@ private static int selectMinutetime(String waitTime) {
return 0;
}
}

public static void selectedDeleteCheck(String quickDeleteCheck) {
String selectDeleteCheck = "";
switch (quickDeleteCheck) {
case "Delete files":
selectDeleteCheck = SettingsConstants.CHECKBOX_DELETE_FILE;
break;
case "Delete draft and submitted forms":
selectDeleteCheck = SettingsConstants.CHECKBOX_DELETE_DRAFT_SUBMITTE_DFORMS;
break;
case "Delete server settings":
selectDeleteCheck = SettingsConstants.CHECKBOX_DELETE_SERVER_SETTING;
break;
default:
System.out.println("[WARNING] Opcion invalida");
}
MobileActionManager.waitVisibility(selectDeleteCheck).click();


}

public static void goToHomeFromSecurityPage() {
//La pagina de seguridad esta a dos paginas de la home, por ello simulo dos tab
MobileActionManager.waitVisibility(SettingsConstants.GO_BACK_BUTTON).click();
MobileActionManager.waitVisibility(SettingsConstants.GO_BACK_BUTTON).click();
}

public static void viewCounterMessage(String message) {
Assert.assertTrue(MobileActionManager.waitVisibility(SettingsConstants.VIEW_COUNTER_MESSAGE, message).isDisplayed());
}

public static void theAppIsClosed() throws InterruptedException {
//Esperamos por el cierre de la app y validamos que se haya cerrado
Thread.sleep(6000);
Assert.assertTrue(GenericService.verifyActiveAppTella());
}
}
16 changes: 9 additions & 7 deletions src/main/java/com/crowdar/tella/services/UnlockService.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public static void isViewLoadedReopenAppWithPassword() {

public static void isViewLoadedReopenAppWithPin() {
if (MobileActionManager.isAndroid()) {
MobileActionManager.waitVisibility(LockUnlockConstants.REOPEN_APP_PIN_VERIFICATION);
MobileActionManager.click(LockUnlockConstants.REOPEN_APP_PIN_VERIFICATION);
} else {
MobileActionManager.waitVisibility(LockUnlockConstants.REOPEN_APP_PIN_VERIFICATION);
MobileActionManager.click(LockUnlockConstants.REOPEN_APP_PIN_VERIFICATION);
} else {
GenericService.commonClick(LockUnlockConstantsIOS.REOPEN_APP_PIN_VERIFICATION);
}
}
Expand All @@ -59,7 +59,7 @@ public static void enterPassword(String password) throws InterruptedException {
MobileActionManager.setInput(LockUnlockConstants.PASSWORD_INPUT, password);
EventFiringWebDriver driver = DriverManager.getDriverInstance();
driver.getKeyboard().sendKeys(Keys.ENTER);
}else{
} else {
Thread.sleep(1000);
MobileActionManager.waitVisibility(LockUnlockConstantsIOS.PASSWORD_INPUT);
MobileActionManager.waitClickable(LockUnlockConstantsIOS.PASSWORD_INPUT);
Expand Down Expand Up @@ -132,11 +132,11 @@ public static void setPin(String pin) {
}
}

public static void enterPin(String pin) {
public static void enterPin(String pin) {
setPin(pin);
if (MobileActionManager.isAndroid()) {
MobileActionManager.click(LockUnlockConstants.PIN_OK_BUTTON);
}else {
} else {
GenericService.commonClick(LockUnlockConstantsIOS.PIN_OK_BUTTON);
}
}
Expand Down Expand Up @@ -203,5 +203,7 @@ public static void reopenTheApp() throws InterruptedException {
driver.activateApp("org.wearehorizontal.tella"); // Usa el package name de tu app para traerla de vuelta al frente


}}}
}
}
}

Loading
Loading