1、获取innerText
java:
WebElement element = driver.findElement(By.id("elementID")); element.getText();
C#:
IWebElement element = driver.findElement(By.id("elementID")); element.Text;
python:
element = driver.find_element_by_id("element_id") element.text
2、操作option元素
java:
WebElement select = driver.findElement(By.tagName("select")); List<WebElement> allOptions = select.findElements(By.tagName("option")); for (WebElement option : allOptions) { System.out.println(String.format("Value is: %s", option.getAttribute("value"))); option.click(); }
C#:
IWebElement select = driver.FindElement(By.TagName("select")); IList<IWebElement> allOptions = select.FindElements(By.TagName("option")); foreach (IWebElement option in allOptions) { Co