我正在尝试使用Selenium WebDriver和Appium在Android上自动化Gmail App。我需要阅读电子邮件内容然后验证它。但是完整元素显示为单个webview,我无法从电子邮件中读取任何文本。请建议一种方式,以便我可以阅读电子邮件内容
使用的代码:
package com.example.appium;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
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;
public class GmailInvoke {
/**
* @param args
* @throws MalformedURLException
* @throws InterruptedException
*/
public static void main(String[] args) throws MalformedURLException, InterruptedException {
DesiredCapabilities capabilities=new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "Android");
//Gmail
capabilities.setCapability("appPackage","com.google.android.gm");
capabilities.setCapability("appActivity", ".ui.MailActivityGmail");
WebDriver driver=new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
List <WebElement> emails = driver.findElements(By.className("android.widget.FrameLayout"));
emails.get(5).click();
System.out.println(driver.findElement(By.id("com.google.android.gm:id/webview")).getText());
Thread.sleep(5000);
driver.quit();
}
}
答案 0 :(得分:0)
我认为无法自动预装应用程序。我也试过了。