Console软件包测试;
import java.net.MalformedURLException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import junit.framework.Assert;
import pages.DashBoardPage;
import pages.LoginPage;
这是loginpageTest的代码,但没有实例化。我觉得某处没有被某事灌输。当我运行此应用程序时,它打开但引发错误,该测试不能被无效化 公共类LoginPageTest扩展了LoginPage {
//DashBoardPage dashBoardPage = new DashBoardPage(driver);
public static WebDriver driver;
LoginPage loginPage;
DashBoardPage ds;
public LoginPageTest() {
super(driver);
ds=new DashBoardPage(driver);
}
@BeforeTest
public void setup() throws MalformedURLException {
intialization();
}
/*@Test(priority = 1)
public void LoginPageTitleTest() {
Assert.assertEquals(getPageTitle(), "verizon");
}*/
// 07/02/2019
@Test(priority =2)
public void VerizonlogoTest() throws InterruptedException {
Thread.sleep(5000);
try{
if(UserID.isDisplayed())
{
clickUserID();
clickPassword();
clickLoginBtn();
}
}
catch(Exception e)
{
System.out.println("Clicking on I Agree Button");
}
finally{
clickAgree();
}
explicitWait(ds.dashBoard);
Assert.assertTrue(ds.getDashBoardTitle().equals("Dashboard"));
/*driver.findElement(By.xpath("//android.widget.EditText[@resource-id='USER']")).sendKeys("jomonli");
driver.findElement(By.xpath("//android.widget.EditText[@resource-id='PASSWORD']")).sendKeys("Brownlenovo5@");
driver.findElement(By.xpath("//android.view.View[@resource-id='btnLogin']")).isEnabled();
Assert.assertTrue(driver.findElement(By.xpath("//android.view.View[@text='Verizon Mobile Single Sign on']")).isDisplayed());
Assert.assertTrue(driver.findElement(By.xpath("//android.view.View[@text='First time user, click here to activate.']")).isEnabled());
*/
//LoginPage loginPage = PageFactory.initElements(driver, LoginPage.class);
//isElementVisible(loginPage.getVerizonLogo());
//loginPage.clickUserID();
}
/*
* @Test(priority = 2, description = "Logo is present Test") public boolean
* VerizonLogoTest() { //boolean logo = loginPage.VerizonLogo();
* //Assert.assertTrue(logo); //return logo; }
*
* @Test(priority = 3, description = "LoginBtn is clickable and enabled")
* public boolean LoginBtnClickableTest() { //boolean clickable =
* loginPage.LoginBtnClickable(); //Assert.assertTrue(clickable); //return
* clickable; }
*/
//@Test(priority = 4, description = "User is able to login succesfully with valid credentials")
public void LoginTest() {
// dashBoardPage = loginPage.Login(prop.getProperty("userID"),
// prop.getProperty("password"));
}
/*
* @Test(description = "FirstTimeUserLink is clickable and enabled") public
* boolean FirstTimeUserLinkClickableTest() { boolean clickable =
* loginPage.FirstTimeUserLinkClickable(); Assert.assertTrue(clickable);
* return clickable; }
*/
@AfterTest
public void teardown() {
driver.quit();
}
// private Object () {
// // TODO Auto-generated method stub
// return null;
// }
}
这是loginpageTest的代码,但没有实例化。我觉得某处没有被某事灌输。当我运行该应用程序时,它打开但引发错误,该测试不能被设置
================================================ ======================
BASE PAGE
package base;
import java.net.URL;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
public class BaseClass {
public static Properties prop;
public static WebDriver driver;
public static URL url;
public static WebDriver intialization() {
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("deviceName", "Galaxy Tab S3");// setting > about
// phone
cap.setCapability("udid", "624258263526a1e8");
// udid is the device name when you press - cmd adb devices
cap.setCapability("platformName", "Android");
cap.setCapability("platformVersion", "8.0.0");
cap.setCapability("appPackage", "com.verizon.launcher.sdnasit");
cap.setCapability("appActivity", "com.verizon.launcher.webview.WebActivity");
// cap.setCapability(MobileCapabilityType.APP, "Apk file location
// C:\\apkfiles\\AndroidUI.apk"
cap.setCapability("noReset", "True");
cap.setCapability("automationName", "uiautomator2");
cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 60);
// any application will have app package and app activity
// download apk info from playstore
try{
url = new URL("http://127.0.0.1:4723/wd/hub");
}
catch(Exception e)
{
e.printStackTrace();
}
driver = new AndroidDriver(url, cap);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
//LoginPageTest loginPage= new LoginPageTest();
return driver;
}
}