Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98417

Clicking a button refreshes a page (unintended) with selenium python

$
0
0

I am trying to automate an upload of a file to my github repo.

Code:

from selenium import webdriver

browser=webdriver.Chrome(r'C:\Users\Eliran\Desktop\chromedriver')
browser.get('https://github.com/login')

username=browser.find_element_by_id('login_field')
username.send_keys(myemail)

password=browser.find_element_by_id('password')
password.send_keys(mypassword)

sign_in_btn=browser.find_element_by_name('commit')
sign_in_btn.click()

browser.get('https://github.com/DevEliran/DevEliran.github.io/upload/master') #pathing immidiately to "upload files" in my repo
commit=browser.find_elements_by_xpath("/html/body/div[4]/div/main/div[2]/div/form/button")[0] # commit button
upload=browser.find_element_by_class_name('manual-file-chooser')#manually uploading my file
upload.send_keys(myfilepath)
commit.click()

after commit.click() the page refreshes and present an error : "Add some files to include in this commit."

I have double checked every element. Has anyone came across a same problem ?


Viewing all articles
Browse latest Browse all 98417

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>