+
+ public static MainView login(String url, String user, String password, Boolean isTrusted, AndroidDriver driver) throws InterruptedException {
+ LoginForm loginForm = new LoginForm(driver);
+ CertificatePopUp certificatePopUp = loginForm.typeHostUrl(url);
+ if(!isTrusted){
+ WebDriverWait wait = new WebDriverWait(driver, 30);
+ //sometimes the certificate has been already accept and it doesn't appear again
+ try {
+ wait.until(ExpectedConditions.visibilityOf(certificatePopUp.getOkButtonElement()));
+ //we need to repaint the screen because of some element are misplaced
+ driver.rotate(ScreenOrientation.LANDSCAPE);
+ driver.rotate(ScreenOrientation.PORTRAIT);
+ certificatePopUp.clickOnOkButton();
+ }catch (NoSuchElementException e) {
+
+ }
+
+ }
+ loginForm.typeUserName(user);
+ loginForm.typePassword(password);
+ //TODO. Assert related to check the connection?
+ return loginForm.clickOnConnectButton();
+ }
+
+ public static WaitAMomentPopUp createFolder(String folderName, MainView mainView){
+ NewFolderPopUp newFolderPopUp = mainView.clickOnNewFolderButton();
+ newFolderPopUp.typeNewFolderName(folderName);
+ WaitAMomentPopUp waitAMomentPopUp = newFolderPopUp.clickOnNewFolderOkButton();
+ //TODO. assert here
+ return waitAMomentPopUp;
+ }
+
+
+ public static AndroidElement scrollTillFindElement (String elementName, AndroidElement element, AndroidDriver driver) {
+ AndroidElement fileElement;
+
+ if(element.getAttribute("scrollable").equals("true")){
+ HashMap<String, String> scrollObject = new HashMap<String, String>();
+ scrollObject.put("text", elementName);
+ scrollObject.put("element", ( (RemoteWebElement) element).getId());
+ driver.executeScript("mobile: scrollTo", scrollObject);
+ }
+ try {
+ fileElement = (AndroidElement) driver.findElementByName(elementName);
+ } catch (NoSuchElementException e) {
+ fileElement = null;
+ }
+ return fileElement;
+ }
+
+