同样是 9 年义务教育,为什么你这么优秀
现在测试是 ok 的 只要能调试微信的小程序的页面就可以对小程序做自动化了,你有什么难题 我可以帮助你 踩了好多坑
线上 bug 哈哈
信任报道 已经学习
楼主啊 为什么我现在切换还是不行啊 我附上我的代码 帮我看一下,切换的时候就卡住了 然后一直到超时,一直卡住切换那里
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("app","");
capabilities.setCapability("appPackage","com.tencent.mm");
capabilities.setCapability("appActivity", ".ui.LauncherUI");
capabilities.setCapability("deviceName","S889PBJR99999999");
capabilities.setCapability("fastReset","false");
capabilities.setCapability("fullRest","false");
capabilities.setCapability("noRest","true");
capabilities.setCapability("automationName","Appium");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("platformVersion","5.1");
capabilities.setCapability("recreateChromeDriverSessions", "True");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("androidProcess ","com.tencent.mm:tools");
capabilities.setCapability(ChromeOptions.CAPABILITY,options);
AndroidDriver driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
//等待元素加载出来
Thread.sleep(5000);
driver.findElement(By.xpath("//*[@text='发现']")).click();
int width = driver.manage().window().getSize().width;
int height = driver.manage().window().getSize().height;
Thread.sleep(2000);
driver.swipe(width /2, height / 4 + 200,width / 2,height / 4,200);
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@text='小程序']")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@text='京东秒杀']")).click();
System.out.println("当前context:" + driver.getContext());
System.out.println("所有句柄" + driver.getContextHandles());
System.out.println(driver.getPageSource());
Thread.sleep(6000);
//driver.findElement(By.name("去秒杀")).click();
//Thread.sleep(6000);
for(String context : (Set<String>)driver.getContextHandles())
{
System.out.println(context);
if(context.contains("WEBVIEW_com.tencent.mm:tools"))
{
driver.context("WEBVIEW_com.tencent.mm:tools");
System.out.println("已经进入webview");
System.out.println("当前context" + driver.getContext());
System.out.println(driver.getContext());
}
}
driver.closeApp();
driver.quit();
我也觉得是这样 我昨天尝试切换上下文但是始终切换不过去
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("app","");
capabilities.setCapability("appPackage","com.tencent.mm");
capabilities.setCapability("appActivity", ".ui.LauncherUI");
capabilities.setCapability("deviceName","S889PBJR99999999");
capabilities.setCapability("fastReset","false");
capabilities.setCapability("fullRest","false");
capabilities.setCapability("noRest","true");
capabilities.setCapability("automationName","Appium");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("platformVersion","5.1");
capabilities.setCapability("recreateChromeDriverSessions", "True");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("androidProcess","com.tencent.mm:tools");
capabilities.setCapability(ChromeOptions.CAPABILITY,options);
AndroidDriver driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
//等待元素加载出来
Thread.sleep(5000);
driver.findElement(By.xpath("//*[@text='发现']")).click();
int width = driver.manage().window().getSize().width;
int height = driver.manage().window().getSize().height;
Thread.sleep(2000);
driver.swipe(width /2, height / 4 + 200,width / 2,height / 4,200);
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@text='小程序']")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@text='京东秒杀']")).click();
System.out.println("所有上下文" + driver.getContext());
System.out.println("所有句柄" + driver.getContextHandles());
driver.context("WEBVIEW_com.tencent.mm:tools");
Thread.sleep(6000);
System.out.println("已经进入webview");
System.out.println(driver.getPageSource());
System.out.println(driver.getContext());
driver.quit();
切换微信小程序的 webview 的时候报错 我真的很疑惑,楼主帮帮我