dual-salmonD
Apify & Crawlee4y ago
7 replies
dual-salmon

How to add xpath in a click function?

The Click function using a CSS Selector is
const buttonSelector = cssSelector;
{some function}
$(buttonSelector).click();

But, When I use Css Selector, the clicking goes on an endless loop, since adding more attributes doesnt work with CSS Selector. So, I decided to use Xpath and modified the code like follows, but, I am getting a syntax error.

const buttonSelector = document.querySelector('//Xpath');
{some function}
$(buttonSelector).click();

How can I correct this to make it work?
Was this page helpful?