Reputation: 69
Please can someone point me to the right direction with below code?
driver.findElement(By.id("div#h4clock a.location").equals("London"));
I used getText("London")
but it did not work.
I am quite new so any advise would be very much appreciated.
I also want to have a string to store the element London and display it using Println
.
Many thanks in advance,
Hamid
Upvotes: 1
Views: 166
Reputation: 16201
The selector does not look like as an id
that cssSelector. Try
driver.findElement(By.cssSelector("div#h4clock a.location")).getText().equals("London");
Edit:
WebElement city = driver.findElement(By.cssSelector("div#h4clock a.location"));
String getcity = city.getText();
System.out.println(getcity);
Upvotes: 1