package basic_scenario;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.UnreachableBrowserException;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class Login_TG {
WebDriver driver;
@BeforeTest
public void setup() throws MalformedURLException
{
String apkpath="C:\\Users\\rgi-40\\android-sdks\\platform-tools\\AG.apk";
File app=new File(apkpath);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserName", "");
capabilities.setCapability("deviceName", "emulator-5554");
capabilities.setCapability("PlatformVersion", "6.0");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("noReset", true);
capabilities.setCapability("appActivity", "com.AG.BaseClasses.Navigation.Activity.SplashScreenActivity");
capabilities.setCapability("appPackage", "com.AG");
capabilities.setCapability("autoGrantPermissions",true);
capabilities.setCapability("newCommandTimeout", "60");
capabilities.setCapability("automationName", "Appium");
//capabilities.setCapability("--session-override",true);
try {
driver = new RemoteWebDriver(new URL("http://127.0.0.1:5038/wd/hub"), capabilities);
} catch(UnreachableBrowserException e){
System.out.println("cant find driver");
}
}
@Test
public void testLogin() throws Exception {
WebElement login_element = driver.findElement(By.id(""));
login_element.click();
WebElement uname_element = driver.findElement(By.className(""));
uname_element.sendKeys("");
WebElement pwd_element = driver.findElement(By.id(""));
pwd_element.sendKeys("");
WebElement submit_element = driver.findElement(By.id(""));
submit_element.click();
}
@AfterTest
public void teardown() {
driver.quit();
}
}
windows 10 os check error screenshot Appium版本= 1.6.1 日食:霓虹灯3。
第一个完整的代码运行完美,但运行多次测试后显示 " unreachablebrowserexception"
我无法处理无法访问的浏览器异常
如果我使用androiddriver和appiumdriver,
我无法在testLogin()
方法中获取元素。