Python Forum
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()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  use Xpath in Python :: libxml2 for a page-to-page skip-setting apollo 2 3,578 Mar-19-2020, 06:13 PM
Last Post: apollo
  'For' command and filling excel table with pandas by doing web-scrabbing fyec 1 2,411 Jul-28-2018, 10:57 AM
Last Post: shinemic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020