2016-06-10 92 views
1
我使用此代码,以便在我的Android(本机应用程序)设备使用硒和Appium找到一个元素

查找和使用元素硒和Appium

var wait = new WebDriverWait(_driver,TimeSpan.FromSeconds(15)); 
var phone = wait.Until(x => x.FindElements(By.Id("foo"))); 

的问题是,发现硒元素只是貌似。意思是找到它,但根本没有属性。

但在使用时:

System.Threading.Thread.Sleep(5000) 

一切就像一个魅力。

我试图增加司机的等待秒数,但它没有帮助。

+0

好像除了一个重复 – nullpointer

+0

前一个是由于删除了错误的描述 –

回答

0

我认为元素在脚本执行操作时没有被加载。 尝试该元素

WebDriverWait wait = new WebDriverWait(driver, 60); 
wait.until(ExpectedConditions.visibilityOfElementLocated(By.locator); 
+0

进行任何操作之前增加一个清晰视野检查,对IList的,我们可以用这个: wait.Until( ExpectedConditions.PresenceOfAllElementsLocatedBy(By.Locator) –