Tag Info

New answers tagged


You should try to avoid xpath. It's usually slow in comparison with other methods, and when trying to get nested elements, xpaths can be get long and unmantainable. Anyhow, if what you want is to just pull the visible string, you can use yourElement.getText() In this particular case, if you want to get the texts into a list, you could simply do something ...


You need to get innerHTML attribute of the div. Try this: System.out.println(driver.findElement(By.xpath("//*[@class='ms-txt']/div")).getAttribute("innerHTML"));


Try using this: WebElement e = driver.findElements(By.xPath("//a/..")); It will select the parent element, the div in this case, of every a. If you want to add a predicate (that is, a condition) for which to filter, you can do this: WebElement e = driver.findElements(By.xPath("//a[contains(@href, 'http:')]/..")); I chose // as start, which searches the ...


You can try creating xpath with text() like these: //span[contains(text(),'Users') //span[contains(text(),'Contents')


As per given description, it seems that list of users will be maintained in HTML's List Item having common title=List of Users. So you can use something like below code to click on dynamic list items(here, users). List<WebElement> Userlist = driver.findElements(By.cssSelector("a[title='List of Users']"); for(WebElement ulist : Userlist) { ...


//h4[contains(text(),'Some regular text ')] You are starting correct, though the first part, //h4[contains(text(),'Some regular text ')], looks for any h4 at any depth, with among its immediate children a text node containing Some regular text. Meaning, if that text appears after the strong element, it will also match the h4. ...

Top 50 recent answers are included