Selenium and xpath – locate an element using id attribute

Issue : Locate the following element using its ID.

<div id="globalContainer">
    <div>
        ...
    </div>
</div>

Resolution : You can write the following query in the browser console.

$x(//div[@id="globalContainer"])

Further Reading

You may also like...