Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 page navigation & form filling
#1
OS: Windows 7, Python 3.6

I'm needing a command prompt script that will connect to a webpage and allow the user to log into the site using their username and password, asking user for the information and then simulate filling out the form and clicking the appropriate button to continue logging in. After entering the correct credentials I need the script to be able to simulate clicking on a series of buttons on the page, cycling through and adding the values in one of the columns depending on the value, (in this case adding up all the Cs or Ss and to finally tally at the end after clicking next to the last page of the table). I was going to use requests as it can fill out the form fields but it can not simulate clicking the buttons. So I decided to use "selenium" but so far all my script does is launch Chrome after I enter my credentials, I don't need it to actually launching the browser, and it's not even launching Chrome to the URL specified either. Any ideas/suggestions? Thanks.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

username = input("Input your username: ")
password = input("Input your password: ")

driver = webdriver.Chrome("C:\\Users\\user\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe")
driver.get("URL.html")
assert "{PAGE-TITLE}" in driver.title

elem = driver.find_element_by_id("inptUserId")
elem.send_keys(username)
elem = driver.find_element_by_id("password")
elem.send_keys(password)
elem.send_keys(Keys.Return)

# the rest of the program will go here

driver.close()
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  'For' command and filling excel table with pandas by doing web-scrabbing fyec 1 590 Jul-28-2018, 10:57 AM
Last Post: shinemic

Forum Jump:


Users browsing this thread: 1 Guest(s)