On 11/04/2016 02:08 PM, David wrote:
> Why do you need this for an existing instance of FF? If it's just to
> exploratory test some stuff out and run some automated interaction with
> manual interaction in the same browser session, you should run Selenium
> commands with python shell (not python script) and/or start Selenium from
> script to run some automation first but which breakpoints out later for you
> to do manual stuff in the
> session:
http://daguar.github.io/2014/06/05/just-dropped-in-interactive-coding-in-ruby-python-javascript/
>
The whole idea is to get rid of manual interaction. I want to write some
one click logon scripts or or a script to get a site in a state that
makes it easy for me to interact with it. Right now my focus is on
Python so when I learned of Selenium I set out to see if I could make it
do what I wanted. If Selenium needs to open a new Firefox window every
time I run a script it is not the solution I was hoping for.
So can Selenium use an existing instance of Firefox to run my scripts?
For instance can this script be modified to run in an instance of
Firefox already running on my desktop?
# login_yahoo_mail.py
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
driver = webdriver.Firefox()
driver.get('
http://mail.yahoo.com/?.intl=us')
enter_email = driver.find_element_by_id('login-username')
enter_email.clear()
enter_email.send_keys('myemail')
next_button = driver.find_element_by_id('login-signin')
next_button.click()
enter_password =
WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.ID,
'login-passwd'))) #wrapped, should be all on one line
enter_password.send_keys('mypswd')
signin_button = driver.find_element_by_id('login-signin')
signin_button.click()
Regards, Jim