In my Selenium webdriver, I search for text based on a certain keyword:
new WebDriverWait(driver,
TimeSpan.FromSeconds(5)).Until(ExpectedConditions.ElementExists((By.PartialLinkText(stringKeywords))));
I would like to grab the full text I have found and save it into a string. How would I be able to do this? I found this somewhere, but it wont let me use it as a string because it is a IWebElement. Could it help me anyway?
IWebElement txtbox = driver.FindElement(By.PartialLinkText(stringKeywords));
一旦您能够使用PartialLinkText定位 webelement,要提取完整的innerText
您可以使用GetAttribute()
方法,如下所示:
Console.WriteLine(driver.FindElement(By.PartialLinkText(stringKeywords)).GetAttribute("innerHTML"));
string txt = driver.FindElement(By.PartialLinkText(stringKeywords)).Text;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.