0

Ive got to programmatically click a cookie accept button when a page loads. I tried a few different addons that are showed online. Those did not work...

The button has the following code:

<a id="acceptAllPrivacyOptionsAtag" class="bcGiveConsent bcpConsentButtonAtag bcpConsentOKButtonAtag" aria-label="accept all privacy options" role="button"> accept all cookies  </a>

Is there a way to do this in javascript? I have to execute the code in bash shell when the page loads.

  • 1
    You can easily do it in JavaScript of course, using getElementById('acceptAllPrivacyOptionsAtag').click(). However, how will you run that from bash? Well, you can't. So, as simple as it sounds like it should be, you probably need something like Selenium: https://stackoverflow.com/questions/1231975/i-want-to-run-selenium-test-case-file-from-command-line – see sharper Jul 06 '21 at 06:16

2 Answers2

0

Well, there is a thing called Alert() it would be alright when page loads, not the best option tho.

Nikivan
  • 1
  • 2
0

Refering to this answer.

Add a script tag at the bottom portion of your html code and trigger a click event manually.

document.getElementById('acceptAllPrivacyOptionsAtag').click()

Nitheesh
  • 19,238
  • 3
  • 22
  • 49