Commit eaad682e authored by Sergey Nazarenko's avatar Sergey Nazarenko
Browse files

Changed architecture.

Made Capabilities single class
parent 59965421
This diff is collapsed.
package pages;
package Pages;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
......@@ -38,20 +38,21 @@ public class LoginPage {
public void invalidLogin() throws InterruptedException {
driver.findElement(signIn).click();
for (String invalidPhone : invalidLoginPhone) {
driver.findElement(phoneInput).clear();
driver.findElement(phoneInput).sendKeys(invalidPhone);
wait(10);
driver.findElement(signIn).click();
for (String invalidPhone : invalidLoginPhone) {
driver.findElement(phoneInput).clear();
driver.findElement(phoneInput).sendKeys(invalidPhone);
// try {
// driver.findElement(By.xpath("//*[contains(text(),'The phone number entered is not valid')]"));
// }catch (NoSuchElementException ex){
// System.out.println(ex);
// }
driver.hideKeyboard();
driver.findElement(sendCode).click();
driver.findElement(phoneInput).clear();
}
driver.hideKeyboard();
driver.findElement(sendCode).click();
driver.findElement(phoneInput).clear();
}
}
public void validLogin() {
......
package Pages;
import org.openqa.selenium.By;
public class Selectors
{
By signIn = By.id("btn_sign_in");
By signIn2 = By.id("btn_sing_in");
By createAccount = By.id("btn_create_account");
By phoneInput = By.id("et_phone");
By sendCode = By.id("btn_send_code");
By keyInput = By.id("et_security_key");
}
package Pages;
public class Users
{
public String User_A_Phone = "+380502972012";
public String User_A_SmsCode = "111111";
public void User_A(String phone, String Code)
{
this.User_A_Phone = phone;
this.User_A_SmsCode = Code;
String User_A_Phone = "+380502972012";
String User_A_SmsCode = "111111";
}
}
package Utils;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.MalformedURLException;
import java.net.URL;
public class AndroidSetup
{
public AndroidDriver driver;
public AndroidSetup(AndroidDriver driver) {
this.driver = driver;
}
public static String White = "2101322bd623a34a";
public static String Black = "42031589dcde8100";
private String UDID;
private String Path = "/home/master/Desktop/Snaapy_07.07.17_11.15.apk";
private String Platform = "Android";
private String DeviceName = "device";
private String AutomationName = "Appium";
String device;
public String GetUDID(String UDID) throws InterruptedException {
if (UDID == Black)
{
device = Black;
Capabilities(Black);
}
else
{
Capabilities(White);
}
return device;
}
private void Capabilities(String device) throws InterruptedException {
this.UDID = device;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("automationName", AutomationName);
capabilities.setCapability("platformName", Platform);
capabilities.setCapability("udid", UDID);
capabilities.setCapability("deviceName", DeviceName);
capabilities.setCapability("app", Path);
try {
AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
}
package scenario;
package Scenario;
import Utils.AndroidSetup;
import io.appium.java_client.android.AndroidDriver;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.*;
import pages.LoginPage;
import Pages.LoginPage;
import java.net.URL;
import static Utils.AndroidSetup.Black;
import static Utils.AndroidSetup.White;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class AppiumTest {
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class AppiumTest
{
AndroidDriver driver;
String samsungWhiteUDID = "2101322bd623a34a";
String samsungBlackUDID = "42031589dcde8100";
AndroidSetup androidSetup = new AndroidSetup(driver);
@BeforeTest
public void setUp() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("automationName", "Appium");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("udid", "2101322bd623a34a");
capabilities.setCapability("deviceName", "device");
capabilities.setCapability("app", "/home/master/Desktop/Snaapy_07.07.17_11.15.apk");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
@BeforeTest
public void setUp() throws Exception
{
//Here you change device UDID (ex. Black or White samsung)
//If you want to add new UDID, set it up in Utils/AndroidSetup.java
androidSetup.GetUDID(Black);
// DesiredCapabilities capabilities = new DesiredCapabilities();
// capabilities.setCapability("automationName", "Appium");
// capabilities.setCapability("platformName", "Android");
// capabilities.setCapability("udid", "42031589dcde8100");
// capabilities.setCapability("deviceName", "device");
// capabilities.setCapability("app", "/home/master/Desktop/Snaapy_07.07.17_11.15.apk");
// driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
@AfterTest
public void tearDown() throws Exception {
public void tearDown() throws Exception
{
driver.quit();
}
......@@ -39,7 +49,6 @@ public class AppiumTest {
@Test(priority = 1)
public void invalidLogin() throws Exception {
new LoginPage(driver).invalidLogin();
}
@Test(priority = 2)
......
package Snp;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
package scenario;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.MalformedURLException;
import java.net.URL;
public class AndroidSetup {
protected AndroidDriver driver;
protected void prepareAndroidForAppium() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("appium-version", "1.0");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "6.0");
capabilities.setCapability("deviceName", "Nexus");
capabilities.setCapability("app", "/home/master/Desktop/Snaapy_07.07.17_11.15.apk");
driver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment