I have a simple Flask web app for logging into my electric company dashboard. I have a page called essentials. The essentials page has a form set up, for user input.
from flask import Flask, render_template, request from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By import time
> > app = Flask(__name__)
> >
> >
> >
> > @app.route('/')
def home():
> > return render_template('home.html')
> >
> > @app.route('/essentials')
def essentials():
> > return render_template('essentials.html')
> >
> > @app.route('/form', methods=['POST'])
def form():
> > username = request.form.get("user_name")
> > password = request.form.get("password")
> >
> >
> >
> > if __name__ == '__main__':
> > app.run(debug=True)
> >
- Then i have a selenium, web automation python script:
driver = webdriver.Safari()
driver.set_window_size(1100, 800)
driver.get('https://www.firstenergycorp.com/content/customer/jersey_central_power_light.html')
username =
password =
driver.find_element_by_id('loginUsername').send_keys(username)
driver.find_element_by_id('loginPwd').send_keys(password)
driver.find_element_by_id('loginPwd').send_keys(Keys.RETURN)
time.sleep(7)
Question: How do i pass the flask form web user inputs(username, password), into the selenium variables in this case "username" and "password" that it will then use for the automation part?
Aucun commentaire:
Enregistrer un commentaire