I am trying to write a script that clicks on "Buy Now" button on a webpage. You may refer to this link for reference. I have wrote this script:
document.querySelectorAll('._3S6yHr._1i2f2k button')[1].dispatchEvent(new Event('click'))
and this:
document.querySelectorAll('._3S6yHr._1i2f2k button')[1].click()
but none seems to work. How can I overcome this restriction? Any possible workarounds?
PS: jQuery is not available on the page.
Related
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.
Well, there is a thing called Alert() it would be alright when page loads, not the best option tho.
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()
Is there a way to get the link of a button click in a website?
This is the Website
https://onlineradiofm.in/stations/mirchi and there is a play button. I want the link to the play button click so that everytime i open the link, the audio starts playing automatically.
Is there a way to achieve this?
Any help is appreciated
Add jquery code in the page where you want to click the button on page load.
<script>
$(document).ready(function()
{
$("#button-id").trigger("click");
})
</script>
Replace button-id with your button id.
There is no link in the play button, it's a click event. The solution to your problem may differ a lot depending if you own the site you are trying to redirect to the audio or not. In case that the website is owned by you, then you could just create the link you are asking for playing with query string parameters to execute a Js script that clicks the button (like the one proposed by #Pranay kumar 's answer). If you don't own the specified website, then its much harder. In this second case, you could make a python script that clicks the button. An example that may guide you to this solution can be found here. This should work in your case, but the solution would not be a link, it would be a script.
I'm trying to click a "Download" button in a pop-up on a webpage. When I click it using Selenium (Chrome; Python), I know it's working because the file gets downloaded.
However, in addition to the javascript that downloads the file, the button has an href=# which should re-direct to the underlying page, (without the pop-up) once it's been clicked. When I click it in a live session using my mouse, the behavior is correct. But when using [button].click() in Selenium, the redirection is not happening - only the file download. Any tips or suggestions?
Edit: code snippets
Here is the button html:
<div class="buttons popup__buttons">
<a href="#" class="button js-downloadLink">
Download
</a>
</div>
And my selenium code:
driver.find_element_by_class_name('button.js-downloadLink').click()
My suggest is to open chrome dev-tools and investigate what action is triggered by javascript. You may need to run a function with selenium that for some reason is not calling when using Selenium or check if the ids are loading properly.
if you want help share the website you want to scrape and we can have a look.
Every website is a new world! Hope it helps.
EDIT:
Still no idea with your snippet. Try the devtool. More precisely to the event listeners where its says click():
I have a site which is already installed intercom and it works well.
I want for intercom to act when I click a hyper link. like below.
I found the docs, but I couldn't find any hint. Is it possible? if possible, what should I do?
I'm new to google chrome extensions, but I'm quite familiar with HTML and some javascript. My main area of expertise is Objective-C (but that's a different area).
I wanted to build a chrome extension where I want to replace a website's button with a different custom button (The button uses a specific class/ID). For example if a website were to have a button that said "Tweet Us" I would want to change it to "Email Us", change the onClick action and the button image.
I was wondering if anyone knows of any tutorials or samples that touch on this. Most that I've ran into focus more on building UIs by the bookmark browser, but I don't really have use for that.
Start with reading this.
Add to the manifest.json the URL you want to manipulate under "matches".
Also add to the manifest.json your JavaScript + css (under "content_scripts").
In the JavaScript write some code that deletes the current button and replace it with your button and
your event for that button.
The easiest way to write it is with Jquery.