'CefSharp how i click button
= Add to Cart
browser.ExecuteScriptAsyncWhenPageLoaded("document.getElementsByClassName('btn_addtocart').click()")
not working pls help ,, thanks
Solution 1:[1]
document.getElementsByClassName returns a https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection which is an array like object. You cannot call click directly on the collection, you must select an element from with the collection.
document.getElementsByClassName('btn_addtocart')[0].click();
Personally I prefer to use query selector for fetching a single html element.
document.querySelector('.btn_addtocart').click();
https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
Anything you are having problems with JavaScript I'd suggest running your script directly in DevTools. See https://github.com/cefsharp/CefSharp/wiki/Trouble-Shooting#javascript-debugging
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | amaitland |
