-3
我需要創建一個簡單的循環遍歷列表並搜索特定的文本。當找到文本時,它應該向下滾動到該選項,以便它可見,然後單擊它。我想出了這樣的事情,但它在Java中,我需要在C#代碼,任何一個可以幫助我的語法,因爲我剛剛學習c#硒迭代列表C#
public static IWebElement FindListItem(IWebElement listContainer, string itemText)
{
List<IWebElement> allOptions = listContainer.FindElements(By.XPath(""));
for (WebElement we: allOptions)
{
listContainer.sendKeys(Keys.DOWN);
sleep(250);
if (we.getText().contains(text)) select.selectByVisibleText("Value1");
}
}
.getText有下劃線用消息「IWebElement不包含定義爲‘的getText’和沒有擴展方法‘的getText’接受型的第一參數‘IWebElement’可以發現」 任何想法我怎麼能解決這個問題? –
請嘗試webElement.Text並讓我知道。 –
不可使用的成員'IWebElemnent.Text'不能像方法一樣使用 –