-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Closed
Labels
C-javaJava BindingsJava Bindings
Description
Selenium Version: 3.12.0
Current version of WebElement::getText says that result will be "without any leading or trailing whitespace", which makes me think that String::trim method is used before value is returned.
This is not true:
Expected Behavior -
Option1: getText() must always trim result according to javaDoc.
Option2: javaDoc must indicate that there are exceptional cases
Actual Behavior -
getText() does not always trim result
Steps to reproduce -
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class T {
public static void main(String[] args) {
WebDriver webDriver = new ChromeDriver();
webDriver.get("https://jsfiddle.net/2dp8Lc90/show/");
new WebDriverWait(webDriver, 10).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(0));
String styledText = webDriver.findElement(By.id("styled")).getText();
String preformattedText = webDriver.findElement(By.id("preformatted")).getText();
System.out.println("Does trim() affect resulted text in case#1="
+ !styledText.trim().equals(styledText)
+ " case#2="
+ !preformattedText.trim().equals(preformattedText));
webDriver.quit();
}
}Metadata
Metadata
Assignees
Labels
C-javaJava BindingsJava Bindings