Is there a another way to upload file with selenium? - python

So I've been trying to automate a task of uploading a contacts file to a phone. The contact file can be uploaded in the web gui for the phone, I've managed to get it get to the page and select the right field but it just highlights it blue and doesn't upload the file as you can see here
import time
import selenium
from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager
from selenium.webdriver.firefox.options import Options
options = Options()
options.AcceptInsecureCertificates = True;
driver = webdriver.Firefox(options=options)
driver.get('xxxx')
### Logging in
user_box = driver.find_element("id", "idUsername")
user_box.send_keys('xxx')
pass_box = driver.find_element("id", "idPassword")
pass_box.send_keys('xxx')
login_button = driver.find_element("id", "idConfirm")
login_button.click()
### Waiting for the page to load
time.sleep(5)
### Uploading the file
chose_file = driver.find_element('xpath', '//button[contains(#onclick, "importxml")]')
chose_file.send_keys('file_location')
time.sleep(5)
driver.close()
Is there another way of uploading file other than using send.keys?
Below is the button in HTML if that helps
<td colspan="2">
<input id="importxml" type="text" yltype="file" class="upload_file_input" readonly="readonly" filedesp="{'maxlength':'2MB', 'action':'contactxml', 'filetype':'contactxml'}" value="" onclick="YLFile.SelectFile('importxml')" />
<button type="button" class="minWidth" id="btn_select" onclick="YLFile.SelectFile('importxml')"><script>T("Browse...")</script></button>
<div>
<button type="button" class="minWidth" id="btn_upload" name="LocalbtnImportXML" level="item" onclick="Contact.UploadXML()"><script>T("Import XML")</script></button>
<button type="button" class="minWidth" id="btn_download" name="LocalbtnExportXML" level="item" onclick="Contact.DownloadFile('downloadxml')"><script>T("Export XML")</script></button>
</div>
<div id="file_widget" style="display:none;"> </div>
<div id="upload_result" class="upload_result_box">
<div class="upload_progress_bar" id="_progress_importxml" style="display:none;">
<div id="progress_bar" class="progress_bar"></div><span id="progress_text">0%</span>
</div>
<div id="info_text_importxml" class="upload_result" style="display:none;"></div>
</div>
<script> YLFile.InitUploadFiles("importxml"); </script>
</td>

Related

Automate the login to the flipkart advertising console using selenium with python

I'm trying to login to a this website: https://advertising.flipkart.com/
I need to download and automate some reports as their console is not great but its been a while since I've used selenium and I'm drawing a blank. I'm trying to use the placeholder texts inside the form to identify the login fields but can't get it to work.
Here's the HTML of the form element where I've isolated the input fields for login, password, and submit button:
<form>
<div class="styles__Row-sc-18s7njp-1 gUWbda">
<div class="styles-erqysw-0 bIQCUh">
<div class="styles__HeadingWrapper-erqysw-3 cIXYhi">
<div class="styles__Title-etu0th-0 cOPdhu"> Email address </div>
</div>
<div class="styles__TextFieldWrapper-sc-19rh1qy-6 lkVOVS">
<div class="styles__Container-sc-19rh1qy-0 dhcObI">
<input type="text"
placeholder="Enter email"
name=""
autocomplete="off"
class="styles__StyledInput-sc-19rh1qy-4 cMJHIl"
value="USERNAME GOES HERE">
</div>
</div>
</div>
</div>
<div class="styles__Row-sc-18s7njp-1 eAthVO">
<div class="styles-erqysw-0 bIQCUh">
<div class="styles__HeadingWrapper-erqysw-3 cIXYhi">
<div class="styles__Title-etu0th-0 cOPdhu"> Password </div>
</div>
<div class="styles__TextFieldWrapper-sc-19rh1qy-6 lkVOVS">
<div class="styles__Container-sc-19rh1qy-0 dhcObI">
<input type="password"
placeholder="Enter password"
name=""
autocomplete="off"
class="styles__StyledInput-sc-19rh1qy-4 cMJHIl"
value="PASSWORD GOES HERE">
<div class="styles__EyeContainer-sc-19rh1qy-3 jyEHZI"><svg width="24px" height="24px"
viewBox="0 2 24 24" color="#363D41">
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g>
<g>
<path
d="M18.1660156,11.75 C18.1660156,11.8776048 18.0748707,12.1601541 17.8925781,12.5976562 C17.6464831,13.1901071 17.3639339,13.686847 17.0449219,14.0878906 C16.5162734,14.7350293 15.8828162,15.2454408 15.1445312,15.6191406 C14.2330684,16.0748721 13.1849018,16.3027344 12,16.3027344 C10.8150982,16.3027344 9.76693164,16.0748721 8.85546875,15.6191406 C8.10806918,15.2454408 7.47461197,14.7350293 6.95507812,14.0878906 C6.64518074,13.6959616 6.36718873,13.1992218 6.12109375,12.5976562 C5.92968654,12.1601541 5.83398438,11.8776048 5.83398438,11.75 C5.83398438,11.6223952 5.92968654,11.3398459 6.12109375,10.9023438 C6.36718873,10.3007782 6.64518074,9.80403842 6.95507812,9.41210938 C7.4837266,8.76497072 8.11262656,8.25455916 8.84179688,7.88085938 C9.75325977,7.42512793 10.8059836,7.19726562 12,7.19726562 C13.1940164,7.19726562 14.242183,7.42512793 15.1445312,7.88085938 C15.8919308,8.25455916 16.525388,8.76497072 17.0449219,9.41210938 C17.3639339,9.81315305 17.6419259,10.3098929 17.8789062,10.9023438 C18.0703135,11.3398459 18.1660156,11.6223952 18.1660156,11.75 Z M17.1542969,11.75 C16.9264312,11.0481736 16.6302102,10.4739606 16.265625,10.0273438 C15.8372374,9.48046602 15.3177114,9.05664213 14.7070312,8.75585938 C13.9414024,8.36393033 13.0390677,8.16796875 12,8.16796875 C10.9609323,8.16796875 10.0540403,8.36393033 9.27929688,8.75585938 C8.66861674,9.06575676 8.14909068,9.48958064 7.72070312,10.0273438 C7.35611797,10.4739606 7.05989697,11.0481736 6.83203125,11.75 C7.05989697,12.4518264 7.35611797,13.0260394 7.72070312,13.4726562 C8.14909068,14.0104194 8.66861674,14.4342432 9.27929688,14.7441406 C10.0540403,15.126955 10.9586537,15.3183594 11.9931641,15.3183594 C13.0276744,15.3183594 13.9322878,15.126955 14.7070312,14.7441406 C15.326826,14.4342432 15.8463521,14.0104194 16.265625,13.4726562 L16.2792969,13.4726562 C16.6347674,13.0260394 16.9264312,12.4518264 17.1542969,11.75 Z M13.6679688,10.0683594 C14.1328148,10.5240908 14.3652344,11.0800748 14.3652344,11.7363281 C14.3652344,12.3925814 14.1350934,12.9508441 13.6748047,13.4111328 C13.2145159,13.8714216 12.6562533,14.1015625 12,14.1015625 C11.3437467,14.1015625 10.7854841,13.8714216 10.3251953,13.4111328 C9.86490655,12.9508441 9.63476562,12.3925814 9.63476562,11.7363281 C9.63476562,11.0800748 9.86490655,10.5218122 10.3251953,10.0615234 C10.7854841,9.60123468 11.3437467,9.37109375 12,9.37109375 C12.6562533,9.37109375 13.2122373,9.6035133 13.6679688,10.0683594 Z M12.984375,10.7519531 C12.7109361,10.4785143 12.3828144,10.3417969 12,10.3417969 C11.6171856,10.3417969 11.2890639,10.4785143 11.015625,10.7519531 C10.7421861,11.025392 10.6054688,11.3535137 10.6054688,11.7363281 C10.6054688,12.1191425 10.7421861,12.4472643 11.015625,12.7207031 C11.2890639,12.994142 11.6171856,13.1308594 12,13.1308594 C12.3828144,13.1308594 12.7109361,12.994142 12.984375,12.7207031 C13.2578139,12.4472643 13.3945312,12.1191425 13.3945312,11.7363281 C13.3945312,11.3535137 13.2578139,11.025392 12.984375,10.7519531 Z"
fill="#363D41" fill-rule="nonzero"></path>
</g>
</g>
</g>
</svg></div>
</div>
</div>
</div>
<div class="styles__ForgetPassWrapper-fg24yr-1 eqzIXq"><a href="/forgot-password"
class="styles__Anchor-sc-5941cr-2 kYQwHs">
<div class="styles__TextContainer-sc-5941cr-0 cCBwan">Forgot Password?</div>
</a></div>
</div>
<div class="styles__Row-sc-18s7njp-1 gUWbda">
<div class="styles__Row-sc-18s7njp-1 gUWbda">
<button type="submit"
class="styles__DefaultButton-sc-5941cr-1 hHuXf">
<div class="styles__TextContainer-sc-5941cr-0 cCBwan">Login</div>
</button>
</div>
<div class="styles__BoxContentCenter-sc-18s7njp-3 kqkvB">
<div class="styles__Label-sc-18s7njp-9 jIhEMq"> Do not have an account? </div>
<div class="styles__Row-sc-18s7njp-1 ncyfJ"><a href="/register" class="styles__Anchor-sc-5941cr-2 kYQwHs">
<div class="styles__TextContainer-sc-5941cr-0 cCBwan">Register now</div>
</a></div>
</div>
</div>
</form>
This is the current code I have.
# import selenium module
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
# Login Information
url = "https://advertising.flipkart.com/"
login_id = "USERNAME"
login_password = "PASSWORD"
# Start the session
wd = webdriver.Chrome('./chromedriver')
def login(url, login_id, login_password):
""" This function will login to the website
parameters:
url: url of the website
login_id: login id of the user
login_password: password of the user
returns:
None
"""
# Open the website
wd.get(url)
# Find the input box with placeholder text "Enter email" and enter the login id
wd.find_element_by_xpath("//input[#placeholder='Enter email']").send_keys(login_id)
# Find the input box with placeholder text "Enter password" and enter the password
wd.find_element_by_xpath("//input[#placeholder='Enter password']").send_keys(login_password)
login(url, login_id, login_password)
First, you are using deprecated syntax: find_element_by_* was replaced with find_element(By.*...). The following is a correct way of logging into that website (you can adapt it to your own setup, just make sure you observe the imports, and the part after defining the browser/driver):
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
chrome_options = Options()
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument('disable-notifications')
chrome_options.add_argument("window-size=1280,720")
webdriver_service = Service("chromedriver/chromedriver") ## path to where you saved chromedriver binary
browser = webdriver.Chrome(service=webdriver_service, options=chrome_options)
url = 'https://advertising.flipkart.com/'
browser.get(url)
WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'input[placeholder="Enter email"]'))).send_keys('username#email.com')
WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'input[placeholder="Enter password"]'))).send_keys('password')
print('wrote credentials')
WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'button[type="submit"]'))).click()
print('clicked submit button')
Selenium documentation can be found at https://www.selenium.dev/documentation/
If you were to use inspect element, most browsers allow you to right click on the HTML element (the input fields in this case), and copy the XPath. So for example, for email it would be:
wd.find_element_by_xpath('//*[#id="app"]/div[1]/div[1]/div/div[2]/div/div[2]/form/div[1]/div/div[2]/div/input').send_keys(login_id)
This is not a perfect solution, but since you don't have an id or class, its one of the few solutions available. The biggest downside of this would be if the layout of the page was changed, at which point the XPath would change as well, meaning that you would have to update your script with the new XPath. However, if you only plan to use the script for yourself, this shouldn't be much of a problem.

python selenium checkbox nested label and input

I'm trying to get a checkmark on "Minutes (1993-Present)" from the federal reserve's document filter page with selenium.
https://www.federalreserve.gov/monetarypolicy/materials/
This is my code. I have tried the following ways, I keep get "Message: no such element: Unable to locate element: Unable to locate element"
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver import ActionChains
import time
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("https://www.federalreserve.gov/monetarypolicy/materials/")
link = driver.find_element_by_xpath('//*[#id="article"]/app-root/div/ng-component/div[1]/div/div/form/app-doc-types/div[2]/div/div/div[7]/label/input').click()
link = driver.find_element_by_xpath("//div[#class='form-group']/div/div[7]/label/input[contains(text(), 'Minutes (1993-Present)')]").click()
link = driver.find_element_by_css_selector('div.form-group div:nth-child(7) label input').click()
I sliced some parts of the HTML below.
<app-doc-types><div class="eventSearch__label">
<p class="form-control-static">
<strong><legend class="ng-binding">Type:</legend></strong>
</p>
</div>
<div class="eventSearch__inputs">
<div class="form-group">
<div class="row">
<div class="col-lg-6">
<label>
<input type="checkbox" class="ng-untouched ng-pristine ng-valid">
Agendas
</label>
</div><div class="col-lg-6">
<label>
<input type="checkbox" class="ng-untouched ng-pristine ng-valid">
Beige Books/Redbooks
</label>
</div><div class="col-lg-6">
<label>
<input type="checkbox" class="ng-untouched ng-pristine ng-valid">
Bluebooks
</label>
</div><div class="col-lg-6">
<label>
<input type="checkbox" class="ng-untouched ng-pristine ng-valid">
Chairman's FOMC Press Conferences
</label>
</div><div class="col-lg-6">
<label>
<input type="checkbox" class="ng-untouched ng-pristine ng-valid">
Greenbooks
</label>
</div><div class="col-lg-6">
<label>
<input type="checkbox" class="ng-untouched ng-pristine ng-valid">
Memos
</label>
</div><div class="col-lg-6">
<label>
<input type="checkbox" class="ng-valid ng-dirty ng-touched">
Minutes (1993-Present)
</label>
</div><!---->
</div>
</div>
</div>
</app-doc-types>
It takes some time for website to load. I added time.sleep(2) after opening the webpage with driver.
Your first XPath should work, however it's extremely dependent on the structure of the page, therefore it may not work due to a little modification in the HTML structure of the page.
Second XPath won't work, and actually you do not need to add text() check to the end of your path. This should work:
//div[#class='form-group']/div/div[7]/label/input
CSS Selector path should work, however your css path can be easily simplified. Check my solution below:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver import ActionChains
import time
driver = webdriver.Chrome()
driver.get("https://www.federalreserve.gov/monetarypolicy/materials/")
time.sleep(2)
link = driver.find_element_by_css_selector('.col-lg-6:nth-of-type(7) input').click()
Alternatively, you can use an explicit wait.
driver.get("https://www.federalreserve.gov/monetarypolicy/materials/")
element = WebDriverWait(driver , 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR , '.col-lg-6:nth-of-type(7) input')))
element.click()
you can use playwright
import asyncio
from playwright.async_api import async_playwright
async def run(playwright):
chromium = playwright.chromium # or "firefox" or "webkit".
browser = await chromium.launch()
page = await browser.new_page()
await page.goto("https://www.federalreserve.gov/monetarypolicy/materials/")
await page.click('xpath=/html/body/div[3]/div[2]/div[2]/app-root/div/ng-component/div[1]/div/div/form/app-doc-types/div[2]/div/div/div[7]/label/input')
await browser.close()
async def main():
async with async_playwright() as playwright:
await run(playwright)
asyncio.run(main())

Select checkbox using selenium in python

I want to select a checkbox using selenium in python. Following is the HTML of the checkbox. The span element is getting highlighted when hovering the mouse over checkbox
HTML
<div id="rc-anchor-container" class="rc-anchor rc-anchor-normal rc-anchor-light">
<div id="recaptcha-accessible-status" class="rc-anchor-aria-status" aria-hidden="true">Recaptcha requires verification. </div>
<div class="rc-anchor-error-msg-container" style="display:none"><span class="rc-anchor-error-msg" aria-hidden="true"></span></div>
<div class="rc-anchor-content">
<div class="rc-inline-block">
<div class="rc-anchor-center-container">
<div class="rc-anchor-center-item rc-anchor-checkbox-holder"><span class="recaptcha-checkbox goog-inline-block recaptcha-checkbox-unchecked rc-anchor-checkbox" role="checkbox" aria-checked="false" id="recaptcha-anchor" tabindex="0" dir="ltr" aria-labelledby="recaptcha-anchor-label"><div class="recaptcha-checkbox-border" role="presentation"></div><div class="recaptcha-checkbox-borderAnimation" role="presentation"></div><div class="recaptcha-checkbox-spinner" role="presentation"></div><div class="recaptcha-checkbox-spinnerAnimation" role="presentation"></div><div class="recaptcha-checkbox-checkmark" role="presentation"></div></span></div>
</div>
</div>
<div class="rc-inline-block">
<div class="rc-anchor-center-container">
<label class="rc-anchor-center-item rc-anchor-checkbox-label" aria-hidden="true" role="presentation" id="recaptcha-anchor-label"><span aria-live="polite" aria-labelledby="recaptcha-accessible-status"></span>I'm not a robot</label>
</div>
</div>
</div>
<div class="rc-anchor-normal-footer">
<div class="rc-anchor-logo-portrait" aria-hidden="true" role="presentation">
<div class="rc-anchor-logo-img rc-anchor-logo-img-portrait"></div>
<div class="rc-anchor-logo-text">reCAPTCHA</div>
</div>
<div class="rc-anchor-pt">Privacy<span aria-hidden="true" role="presentation"> - </span>Terms</div>
</div>
</div>
I am trying the following code but it is giving following exception selenium.common.exceptions.NoSuchElementException
My Code
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
chromedriver = 'C:\Program Files (x86)\Google\Chrome\chromedriver'
browser = webdriver.Chrome(chromedriver)
browser.get(url)
checkBox = browser.find_element_by_id("recaptcha-anchor")
checkBox.click()
This is a recaptha stuff .. it's not like normal elements in the page
you have to navigate with selenium to the captcha frame .. then you can deal with the checkbox element..
to do that you need first to save the main window handle to be get back to it when you're done with the recaptcha
# save the main window handle
mainwindow = browser.current_window_handle
# get the recapthca iframe then navigate to it
frame = browser.find_element_by_tag_name("iframe")
browser.switch_to.frame(frame)
# now you can access the checkbox element
browser.find_element_by_id("recaptcha-anchor").click()
# navigate back to main window
browser.switch_to.window(mainwindow)
for further info about how to deal with the recaptcha challenge check this link

Selenium Python find element by name doesn't work

I'm testing the web form with several fields using a PyCharm and Selenium web driver.
There are a two similar DIVs on the webpage for a phone and e-mail:
<div class="popup-subscribe-new__content">
<div class="field field_type_email js-field-custom-email js-field">
<input type="phone" name="phone" placeholder="Phone Number" autocomplete="off" required="required" class="field__input js-field-input js-inputmask-phone" pattern="^[0-9\+\-\( \)]+$" data-trim="true" pattern-flags="i">
<div class="field__error">Enter the phone number</div>
</div>
</div>
and
<div class="popup-subscribe-new__content">
<div class="field field_type_email js-field-custom-email js-field">
<input type="email" name="email" placeholder="E-mail" autocomplete="off" required="required" class="field__input js-field-input" pattern="^([A-Za-z0-9_\.\+\-])+#([A-Za-z0-9_\.\-])+\.([A-Za-z]{2,4})$" data-trim="true">
<div class="field__error">Enter the e-mail</div>
</div>
</div>
in my test I using phone_field = driver.find_element_by_name('phone') for the phone search
and email_field = driver.find_element_by_name('email') for the e-mail search
As the result, the test successfully found the phone field but after trying to find the email field the PyCharp answered with ElementNotVisibleException: Message: element not visible
Where was I wrong?
Thank you,
Eugene
You can try this code :
wait = WebDriverWait(browser, 30)
phone_field = driver.find_element_by_name('phone')
phone_field.send_keys('some phone number')
email_field = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'div[class*='js-field-custom-email']>input[name='email']')))
email_field.send_keys("""some#email.com"""")
make sure to import these :
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
Try to wait until element will be visible like this:
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.NAME, "email")))
email_field = driver.find_element_by_name('email')
More information about waits can be found in the documentation here.

Selenium Python. Click on radio-button does not any affect

First of all sorry for my english.
I have a page with radio-buttons.
Here is the html code of the button I want to click.
<label class="radio-button__radio radio-button__radio_side_right radio-button__radio_next-for-pressed_yes" for="uniq13988671">
<input id="uniq13988671" class="radio-button__control" type="radio" value="1000">
<span class="radio-button__text">все</span>
</label>
my python script with selennium:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains as ac
driver = webdriver.Firefox()
driver.get("url_with_elements")
driver.implicitly_wait(20)
my_button = driver.find_element_by_css_selector("input[value='1000']")
ac(driver).move_to_element(my_button).perform()
my_button.click()
This button should reload the page with all elements (at least 1000) but it doesn't work.
Ther's no any errors and element respond on method .get_attribute('id')
>>> my_button.get_attribute('id')
u'uniq13988671'
here is full html code of row with radio-buttons:
<td class="b-layout-table__cell">
<div class="b-banners-per-page i-bem b-banners-per-page_js_inited" onclick="return {"b-banners-per-page":{"urlObject":{"hash":"","query":{"cmd":"setPageSize","subcmd":"showCamp","cid":"8868621","ulogin":"*mylogin*"},"file":"main.NWluTm99mAw1N.pl","directory":"/registered/","path":"/registered/main.NWluTm99mAw1N.pl","relative":"/registered/main.NWluTm99mAw1N.pl","port":"","host":"direct.yandex.ru","password":"","user":"","userInfo":"","authority":"direct.yandex.ru","protocol":"https","source":"https://direct.yandex.ru/registered/main.NWluTm99mAw1N.pl"},"optimalBannersOnPage":20}}">
<span class="b-banners-per-page__title">Объявлений на странице: </span>
<div class="b-banners-per-page__buttons">
<span class="radio-button radio-button_size_s radio-button_theme_normal i-bem radio-button_js_inited" onclick="return {"radio-button":{}}">
<label class="radio-button__radio radio-button__radio_side_left" for="uniq13988675">
<label class="radio-button__radio radio-button__radio_checked_yes radio-button__radio_pressed_yes" for="uniq13988674">
<label class="radio-button__radio radio-button__radio_next-for-pressed_yes" for="uniq13988673">
<label class="radio-button__radio" for="uniq13988672">
<label class="radio-button__radio radio-button__radio_side_right" for="uniq13988671">
<input id="uniq13988671" class="radio-button__control" type="radio" value="1000">
<span class="radio-button__text">все</span>
</label>
</span>
</div>
</div>
</td>
Here's the image of how it looks like "step by step"
http://i.imgur.com/LYqKyqx.png
I'm looking at other questions but they don't help me.
Thanks for any help.
ADD: If i use Selenium IDE addon for firefox. this button clicked fine.
If need more info - please ask.
I've handle my problem use construction like that:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains as ac
driver = webdriver.Firefox()
driver.get("url_with_elements")
driver.implicitly_wait(20)
# my_button = driver.find_element_by_css_selector("input[value='1000']")
button_parent = driver.find_element_by_xpath("//td[2]/div/div/span/label[5]")
ac(driver).move_to_element(button_parent).perform()
button_parent.click()
ac(driver).send_keys(Keys.SPACE).perform()

Categories

Resources