- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在尝试使用 Java 获取 Appium 测试设置以在 Android 上进行测试。为了验证我的元素,我一直在使用 AndroidUiAutomator。在 UI Automator 查看器中,我可以看到可访问性标签已传播(见附图)。当我使用 findElement(By.name|By.AccessibilityId|etc 它通常只是超时,必须重新启动 Appium 服务器终端控制台才能运行测试。我使用 FindByXPath 得到类似的结果。我尝试使用超时和 waitdriver 等待确保元素已加载,但无济于事。我已经尝试了下面代码中列出的几乎所有内容。
/**
* Created by appium on 12/6/16.
*/
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidElement;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.WebDriver;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.Select;
import java.util.*;
import java.net.URL;
public class FirstTest {
AndroidDriver driver;
@Before
public void setUp() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Android Emulator");
capabilities.setCapability("BROWSER_NAME", "Android");
capabilities.setCapability("app", apkloc);
capabilities.setCapability("VERSION", "5.0.0");
capabilities.setCapability("platformName", "Android");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
// Thread.sleep(100);
//driver.manage().timeouts().implicitlyWait(100000, TimeUnit.SECONDS);
System.out.println("driver1=" + driver);
}
@Test
public void login() throws InterruptedException {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
MobileElement mo = (MobileElement) driver.findElementByAndroidUIAutomator("new UiSelector().text(\"username\")");
WebDriverWait wait = new WebDriverWait(driver, 1000);
System.out.println("driver4=" + driver);
WebElement element = driver.findElement(By.xpath("//EditText[@text='username']"));
WebElement elly = driver.findElementByXPath("//[@id=wutitdo]");
System.out.println("olly-mint: "+elly);
WebElement element2 = driver.findElementByName("password");
//WebElement element3 = driver.findElementByXPath("//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.webkit.WebView[1]/android.view.View[4]");
//WebElement element4 = driver.findElementByName("");
//WebElement element3 = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.webkit.WebView[1]/android.view.View[4]")));
// WebElement exp = (WebElement) (new WebDriverWait(driver, 15)).until(ExpectedConditions.presenceOfElementLocated(By.name("Trip")));
System.out.println("dr" + driver);
//element.click();
//WebDriverWait wait = new WebDriverWait(driver, 10);
// element2.click();
Thread.sleep(1000);
//element3.click();
//WebElement current = (new WebDriverWait(driver,100)).until(ExpectedConditions.presenceOfElementLocated(By.name("username")));
//current.sendKeys();
// WebElement dropdown = driver.findElement(By.xpath("//*[@id='wrapper']/table[2]/tbody/tr[24]/td[3]/select[1]"));
//WebElement dropdown = driver.findElement(By.xpath("//*[@id='wrapper']/table[2]/tbody/tr[24]/td[3]/select[1]"));
//Select listbox = new Select(driver.findElement(By.xpath("//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.webkit.WebView[1]/android.view.View[1]/android.view.View[0]")));
//listbox.selectByIndex(0);
//listbox.selectByIndex(3);
//driver.findElement(By.xpath("//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.webkit.WebView[1]/android.view.View[1]/android.view.View[3]")).click();
//Thread.sleep(2000);
//element4.click();
//Thread.sleep(1000);
}
@After
public void tearDown() throws Exception {
System.out.println("driver3=" + driver);
driver.quit();
}
}
[![enter image description here][1]][1]
[1]: /image/JPegT.png
最佳答案
您没有使用默认超时
,因此如果定位器正确,appium 服务器可以获得时间来搜索元素。您应该使用显式等待来正确加载元素。
在功能中添加超时。
capabilities.setCapability("newCommandTimeout", 50);
Use these explicit wait functions based on element type if element is clickable try wait for clickable and if element is not clickable try with element’s visibility only
WebDriverWait wait = new WebDriverWait(driver, 30);
public void waitForMobileElementVisible(MobileElement element)
{
wait.until(ExpectedConditions.visibilityOf(element));
}
public void waitForMobileElementClickable(By by)
{
wait.until(ExpectedConditions.elementToBeClickable(by));
}
关于android - Appium 无法通过 content-description/accessibilityID 找到元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41045003/
什么是 SASS 方法要求干燥这样的东西: .content p, .content ul, .content li, .content a 最佳答案 这 4 个元素都有共同的样式吗? .conten
我正在评估 Contentful.com 作为 Angular SPA 的内容引擎。 我面临的问题是按内容类型检索条目(例如,获取“博客”类型的所有条目)。如 documentation exampl
在我编辑的主 wiki 上有一个名为 Item: 的自定义命名空间,提示是该命名空间内的每个页面都显示为 Item:This_item - - Item:That_item -- Item:Foo_i
我正在尝试编写一个Python脚本,可以将图片和pdf上传到WordPress。我希望图像上传到文件夹‘/wp-Content/Uploads/’,将pdf文件上传到文件夹‘/wp-Content/U
是否可以监控进行了多少次 Contentful API 调用,并理想地在即将超过配额时收到通知? 谢谢 最佳答案 当然,您可以在右侧用户配置文件的下拉菜单 > Organizations and Bi
我在尝试在 IE8 中下载带有分号的文件名时遇到问题。 Response.AddHeader("Content-Disposition", "attachment; filename=\"" + at
我在 Contentful Delivery API 中运行查询以返回基于它的 slug 的特定页面项目。这个查询还设置了语言环境,以便它只返回我需要呈现的语言的数据。 但是,我还需要设置页面的 hr
我有兴趣使用 Gatsby建一个Netlify使用来自 Contentful 的内容的静态网站 Netlify 有这个不错的 Gatsby 入门指南: https://www.netlify.com/
目标是提交一个 git 分支。分支的“git status”的输出是: On branch zeromq_new Your branch is up to date with 'origin/zero
我目前正在学习在 ASP.NET 3.5 和 C# 中使用 MasterPages 和 ContentPlaceHolders - 现在,我正在拼命尝试通过我的编程代码编辑 asp:Content-C
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
我使用 bootstrap 3 作为我的网格框架和 CSS 来创建一个具有一个倾斜/倾斜边缘的半透明区域,但由于分层不透明度,我的元素遇到了问题。 期望是中心是倾斜的,但右侧仍然是正方形。 有没有更好
IllegalArgumentException: 未知 URL 内容:// ^ 对上述内容做了噩梦。我检查了我的变量和路径,但看不出问题是什么?非常感谢任何指点! 这是我的痕迹。 java.lan
我有两个元素:一个是 元素,另一个是 元素。 populated-drop-down extends drop-down ,但是,正如您可能已经猜到的那样,它会尝试使用一些选项预先填充它。假设我可以简
我想我也有同样的问题。 Using multiple yields to insert content 我尝试了这个解决方案。我试过 在我的 application.html.erb 中有 conte
此链接 ( https://css-tricks.com/snippets/css/a-guide-to-flexbox/ ) 表示 justify-content 和 align-content 的
我现在正在探索绑定(bind),并且有一个 NSPopUpButton - 它为我提供了一些值选择下的绑定(bind)选项 - Content , Content Objects , Content
正在尝试在内容页面中加载内容 View 。当我运行代码时,它不会出现在我的内容 View 中。我正在从我的内容页面分配两个可绑定(bind)参数。 内容页面: 内容 View :
我想从我的 :before 标签中获取 content。我知道有些人会说它不是真正的(伪)元素,但在 JS 中有一种方法,但有人可以帮助我在 JQ 中做到这一点,因为我有多个标签并且我想用 $.eac
我创建了一个.sh脚本,并将结果记录在一个文件中,执行后我会尝试将文件内容作为mail正文发送。 这是我运行的命令: sh update.sh >> update.$(date +"%Y-%m-%d:
我是一名优秀的程序员,十分优秀!