2016-06-10 90 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) –