Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.80 KB | None | 0 0
  1. package com.example.appium_tests;
  2.  
  3.  
  4. import io.appium.java_client.remote.AndroidMobileCapabilityType;
  5. import io.appium.java_client.android.AndroidDriver;
  6. import io.appium.java_client.android.AndroidElement;
  7. import io.appium.java_client.TouchAction;
  8. import java.time.Duration;
  9. import io.appium.java_client.remote.MobileCapabilityType;
  10. import io.appium.java_client.touch.WaitOptions;
  11. import io.appium.java_client.touch.offset.PointOption;
  12.  
  13. import org.openqa.selenium.support.ui.ExpectedConditions;
  14. import org.openqa.selenium.support.ui.WebDriverWait;
  15. import org.openqa.selenium.remote.DesiredCapabilities;
  16. import org.openqa.selenium.By;
  17. import org.junit.jupiter.api.*;
  18. import java.net.URL;
  19. import java.net.MalformedURLException;
  20. import java.util.List;
  21. import java.util.logging.Level;
  22.  
  23. public class tc4_tirage_classic {
  24.  
  25.     private AndroidDriver<AndroidElement> driver;
  26.     private DesiredCapabilities dc;
  27.  
  28.     public tc4_tirage_classic(AndroidDriver driver, DesiredCapabilities dc) {
  29.         this.driver = driver;
  30.         this.dc = dc;
  31.     }
  32.  
  33.     public void testtc4_tirage_classic() {
  34.  
  35.         //driver.context("NATIVE_APP");
  36.  
  37.     System.out.println(driver.toString());
  38.  
  39.         //Wait Family range screen
  40.         new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("range_background")));
  41.  
  42.         TestCase.swipe(driver);
  43.         TestCase.swipe(driver);
  44.  
  45.  
  46.         driver.findElement(By.id("range_background")).click();
  47.  
  48.         new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("range_background")));
  49.         driver.findElement(By.id("range_background")).click();
  50.  
  51.         new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("main_button")));
  52.         driver.findElement(By.id("main_button")).click();
  53.  
  54.         new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("tv_quantity_price")));
  55.         driver.findElement(By.id("tv_quantity_price")).click();
  56.  
  57. /*        //Access to device's library = FIRST TIME only !!!
  58.         new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("permission_allow_button")));
  59.         driver.findElement(By.id("permission_allow_button")).click();
  60. */
  61.         //Select album > photos
  62.         new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("adapter_album_grid_name_album")));
  63.         driver.findElement(By.id("adapter_album_grid_name_album")).click();
  64.  
  65.         new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("adapter_picture_grid_thumbnail")));
  66.  
  67.         List<AndroidElement> myElements = driver.findElements(By.id("adapter_picture_grid_thumbnail"));
  68.  
  69.         if (!myElements.isEmpty()) {
  70.  
  71.             for (int i = 0; i < 4; i++) {
  72.                 myElements.get(i).click();
  73.  
  74.             }
  75.         }
  76.  
  77.         driver.findElement(By.id("main_button")).click();
  78.  
  79.         new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("main_button")));
  80.         driver.findElement(By.id("main_button")).click();
  81.  
  82.         //Cart screen
  83.         new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("main_button")));
  84.         driver.findElement(By.id("main_button")).click();
  85.  
  86.         //Sign Up > Sign In screen
  87.         new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("activity_register_goto_login")));
  88.         driver.findElement(By.id("activity_register_goto_login")).click();
  89.  
  90.         try {
  91.             Thread.sleep(1000);
  92.         } catch (InterruptedException e) {
  93.             e.printStackTrace();
  94.         }
  95.  
  96.         String UserEmail = "a241.zubovych@gmail.com";
  97.         String UserPassword = "dui1zsx023";
  98.  
  99.         driver.findElements(By.id("edit_field")).get(0).click();
  100.         driver.findElements(By.id("edit_field")).get(0).clear();
  101.         driver.findElements(By.id("edit_field")).get(0).sendKeys(UserEmail);
  102.  
  103.         driver.findElements(By.id("edit_field")).get(1).click();
  104.         driver.findElements(By.id("edit_field")).get(1).clear();
  105.         driver.findElements(By.id("edit_field")).get(1).sendKeys(UserPassword);
  106.  
  107.         new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("main_button")));
  108.         driver.findElement(By.id("main_button")).click();
  109.  
  110.         //Wait Cart screen again
  111.         new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("main_button")));
  112.         driver.findElement(By.id("main_button")).click();
  113.  
  114.         //Shipper screen
  115.         new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='shipper_name']")));
  116.  
  117.         driver.findElement(By.id("main_button")).click();
  118.         driver.findElement(By.id("main_button")).click();
  119.         driver.findElement(By.id("rb_cb")).click();
  120.         driver.findElement(By.id("et_add_source_card_number_ml")).sendKeys("4242424242424242");
  121.  
  122.         new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("keyboardView")));
  123.         driver.findElement(By.id("et_add_source_expiry_ml")).click();
  124.  
  125.         driver.findElement(By.id("et_add_source_expiry_ml")).sendKeys("1122");
  126.  
  127.         new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("keyboardView")));
  128.         driver.findElement(By.id("et_add_source_cvc_ml")).click();
  129.  
  130.         driver.findElement(By.id("et_add_source_cvc_ml")).sendKeys("333");
  131.  
  132.         new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("back")));
  133.         // driver.findElement(By.xpath("//*[@id='back']")).click();
  134.  
  135.         driver.findElement(By.id("main_button")).click();
  136.         driver.findElement(By.id("main_button")).click();
  137.     }
  138.  
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement