I'm trying to write a script that pushes a button that looks like this in HTML code:
<button type="button" class="button save create">
<img src="img/tick-circle.png" title="" alt="">
Create
</button>
I read this post: Python: clicking a button but I can't figure out how to translate it to my problem because the website I am trying to click a button on does not take me to a new page once the button is clicked. Any suggestions?
Related
I would like to create a button to download the data contained in the table of my HTML page. First of all I thought of saving the data in a table in my database and then create a function that can be called up when the button is clicked (I specify that I would not want to be directed to any page and therefore to remain in the same where the button is). How can I link this function to the button? I tried using onClick() but it doesn't work.
This is the HTML code
<form method="GET" align="center" >
<button onclick="download_file()" id="download-button" class="btn btn-primary btn-lg active" type="submit">Download Table</button>
</form>
Thanks to everyone
I have this html :
<div class="dropdown float-right">
<button class="btn btn-default" type="button" id="export-button" data-toggle="dropdown">
<i class="the-download-export"></i>
Export
</button>
<div class="dropdown-menu dropdown-menu-right"><div class="dropdown-item action-export" data-format="csv" data-store="com" data-reverse-type="single"><i class="text-primary fa fa-upload" aria-hidden="true"></i>Download File</div>
This is a dropdown that has a few options. When the button is clicked, it collapses the dropdown selection and the divs appear(there are more divs for various data formats which i haven't added here for simplicity).
I have tried a few things in order to click the button with the csv data format, but everything has failed. Either not finding it or getting the div only, which is not interactible.
What is the proper way of selecting and clicking this dropdown collapsible button in Python ?
That's very little to work on.
I can recommend either checking whether you can get the data another way (e.g. api call when clicking the button) or something with x-path like
button = getFromXPath(".//button[#id='export-button']")
button.click()
I'm trying to make a selenium script using python that is able to search for a specific text and click on it. Below is an example of the code I'm working with. In this example I'm searching for the string "Next" and clicking on it.
<div class="btn-container text-center">
<button id="btnNext" class="btn btn-lg btn-primary btn-block">Next</button>
</div>
So far I have tried the following:
driver.find_element_by_xpath("//*[#id='btnNext']").click()
driver.find_element_by_id('btnNext').click()
driver.find_element_by_xpath("//*[contains(text(),'" + 'Next' + "')]").click()
driver.find_element_by_xpath("//button[contains(.,'Next')]").click()
But no luck so far. Any suggestions? Thank you for all the help!
I have the below HTML code
<footer class="aui-dialog2-footer">
<div class="aui-dialog2-footer-actions">
<button class=" aui-button aui-button-primary dialog-submit" resolved="">
Add key
</button>
<button class=" aui-button aui-button-link dialog-cancel" resolved="">Cancel</button>
Here is the attached image
I want to click this button using selenium. I have written
driver.find_element_by_xpath("//button[contains(text(),'Add key')]").click()
But this is not clicking the button. I have used find_element_by_class_name but it shows it can't resolve class name. How can I click this button using selenium.
looks like its in other iFrame look if yes just switch to it
I have to click on the first submit on a multi submit form. The submit code is as below:
<div class="grid ">
<div class="grid__item grid-u-2-10">
<label class="form__label">Auto-Fill:</label>
</div>
<div class="grid__item grid-u-8-10" id="autofill-button-container">
<input type="button" id="autofill" name="autofill" value="Auto-Fill" class="form__input" onclick="AutoFill();" /> Use AutoFill first, as it will replace everything below.
</div>
</div>
I tried:
br.open(url+"upload.php")
br.select_form(nr=7)
r = br.submit(label='Auto-Fill')
however it returns:
mechanize._form.ControlNotFoundError: no control matching kind 'clickable', label 'Auto-Fill'
Pls help.
you're trying to click the wrong button. The input-button action is what you need to go for. Assuming you're selecting the right form. If not br.select_form(nr=8)
Try:
br.submit(name=autofill)