Starting ChromeDriver 91.0.4472.101 (af52a90bf87030dd1523486a1cd3ae25c5d76c9b-refs/branch-heads/4472@{#1462}) on port 26426
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Čvc 07, 2021 8:51:23 DOP. org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Field named 'FirstName' has text: No text found
Field named 'LastName' has text: No text found
Field named 'CompanyIdentifier' has text: (provided by HR)
Field named 'Last4OfSSN' has text: (Last 4 Digits of SSN / ID)
Field named 'BirthDate' has text: (mm/dd/yyyy)
Can you try the below code and check if it helps
public static List<String> getSmallText(String locator) {
driver.get("https://qa.employeenavigator.com/benefits/Account/Register");
List<WebElement> element = driver.findElements(By.tagName(locator));
List<String> str = new ArrayList<String>();
if (element.size() == 0) {
System.out.println("No text found");
} else {
for (WebElement e : element)
str.add(e.getText());
return (str);
}
return str;
}
3条答案
按热度按时间erhoui1w1#
您必须找到父元素两次,才能从所需的输入字段中获得标记“small”。
输出:
uurity8g2#
我不理解你的问题,但我假设你想要输入字段中的小写单词。我希望下面的代码将帮助你。
uxh89sit3#