In Selenium Webdriver, how can I extract text from a span tag and print it?
I need to extract the text - "UPS seven days a week - for free"
The HTML is as follows:
div id="customSelect_3" class="select_wrapper"> <div class="select_display hovered"> <span class="selectLabel clear">UPS Overnight - Free</span>
Using the following code:
String kk = wd.findElement(By.xpath(//*[@id='customSelect_3']/div[1]/span)).getText(); System.out.println(kk);
But above the code returns / prints the text - "1" .
java html selenium selenium-webdriver
Onu
source share