So, I have this code, where I am trying to compare the text that I saved in Y variable with the text from x variable. The problem is that eclipse doesn't save in the variable x the text from that locator. If I try to print the variable x I got printed "SECTOR 3, BUCURESTI", which is the same text saved in y. But when I compare them I always get the error message.
String y = "SECTOR 3, BUCURESTI";
WebElement LA = driver.findElement(By.xpath("//a[@href='#']//div//div//div[contains(text(),'SECTOR 3, BUCURESTI')]"));
String x= LA.getText();
if (x == y) {
System.out.println(x);
} else {
System.out.println("error");
}