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...
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.
2 Answers
Must Read
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);