Document. querySelector() Is Not Showing All Elements

I am a novice and trying to design both relative CSS selectors and JSPath to run my automation scripts.

While on the way, I could find the return statements are different between these two. Please check the below example. Could someone tell what changes I need to make in JSPath to keep the results same as relative CSS selectors.

Result of Relative CSS selector.

Result of Relative JSPath.

JS just returns first element while the css selectors returned multiple above. What changes do I need to make in JS to keep the results same.

1

2 Answers

Document.querySelector()

The Document method querySelector() returns the first WebElement within the document that matches the specified selector, or group of selectors. If no matches are found, null is returned.

Note: The matching is done using depth-first pre-order traversal of the document's nodes starting with the first element in the document's markup and iterating through sequential nodes by order of the number of child nodes.

Syntax:

element = document.querySelector(selectors);

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.