Whenever I run this code:
document.querySelector(my_selector)
using selenium, an error is thrown:
Failed to execute 'querySelector' on 'Document' my_selector is not a valid selector
my_selector
is definitely a valid selector that functions correctly in my local chrome browser.
div#some_id > div.some_class_1.some_class_2 > div#another_id > div.md:some_class
Although it contains colons, I escape them by using double backslashes. For the sake of clarity, I use my_selector
as a placeholder since the actual selector is quite lengthy. Any ideas why this error is occurring?
Below is a snippet of the code logic:
function getElelement() {
const elementPath = arguments[0]
return document.querySelector(elementPath)
}
...
...
...
driver.executeScript(getElelement, my_selector)
UPDATE: Ultimately, I decided to pursue a different solution as I couldn't find a resolution to my issue. Appreciate the efforts from everyone who tried to assist!