There are a few different approaches you can take to accomplish this task.
One method involves utilizing a CSS Selector:
driver.findElement(By.cssSelector("#test div"))
// ^ take note of the space, as this signifies a CSS "descendant" selector.
I find the wording of
locate the div tag without any attributes using the divelement variable.
a bit confusing, but if you are looking for a <div>
element without specific attributes, you can utilize the :not()
pseudo-selector.
driver.findElement(By.cssSelector("#test div:not([id])")
// will identify all <div> elements under #test that do not possess an id attribute.
Alternatively, you can achieve the same outcome by chaining findElement
methods like this:
driver.findElement(By.cssSelector("#test")).findElements("div")