As the texts Shooting and Pedestrian Accident are within elements which are text nodes, so to extract the texts you can use the following solutions:
WebElement myElement = driver.findElement(By.cssSelector("div.settings"));
//extracting Shooting
System.out.println(((JavascriptExecutor)driver).executeScript("return arguments[0].firstChild.textContent;", myElement).toString());
//extracting Pedestrian Accident
System.out.println(((JavascriptExecutor)driver).executeScript("return arguments[0].lastChild.textContent;", myElement).toString());
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments