在我的Selenium webdriver中,我根据某个关键字搜索文本:
new WebDriverWait(driver,
TimeSpan.FromSeconds(5)).Until(ExpectedConditions.ElementExists((By.PartialLinkText(stringKeywords))));我想抓取我找到的全文并将其保存为字符串。我怎么才能做到这一点呢?我在某个地方找到了这个,但它不允许我将它用作字符串,因为它是一个IWebElement。不管怎样,这对我有帮助吗?
IWebElement txtbox = driver.FindElement(By.PartialLinkText(stringKeywords));发布于 2019-12-27 20:26:16
使用PartialLinkText定位webelement后,要提取完整的innerText,可以使用GetAttribute()方法,如下所示:
Console.WriteLine(driver.FindElement(By.PartialLinkText(stringKeywords)).GetAttribute("innerHTML"));发布于 2020-01-08 21:39:34
string txt = driver.FindElement(By.PartialLinkText(stringKeywords)).Text;https://stackoverflow.com/questions/59500527
复制相似问题