????????????java+selenium?????????????????????????????????pyhton+selenium???????????????????????python????????????д?????????????????????????????????????UI??????????????????????????????????????????radio?? checkbox?? ????? ??????????????????js????á?
???????????
# coding = utf-8
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
import time
driver=webdriver.Firefox()
driver.maximize_window()
driver.get('c:\test.html')
def button():
btn=driver.find_element_by_id('user')
btn.send_keys('hello')
print('finish')
driver.close()
def select():#se=driver.find_element_by_name('select')
#se.find_element_by_xpath('//option[@value="audi"]').click
se=Select(driver.find_element_by_name('select'))
se.select_by_value('audi')
se.select_by_index(2)
time.sleep(5)
def link():
lk=driver.find_element_by_class_name('baidu')
lktext=lk.get_attribute('text')
print(lktext)
lk.click()
def checkbox():
ck=driver.find_element_by_name('checkbox1')
checked=ck.get_attribute('checked')
print(checked)
ck.click()
def submit():
st=driver.find_element_by_class_name('button')
js='var st=document.getElementsByName("button");st.click()'
driver.execute_script(js)
def js():
input=driver.find_element_by_id('user')
driver.execute_script('arguments[0].value="123"'??input)
def alert():
al=driver.find_element_by_class_name('alert')
al.click()
alert=driver.switch_to_alert()
print alert.__getattribute__('text')
time.sleep(5)
alert.accept()
#alert.dismiss()
def switch():
#switch_to_window?? switch_to_frame
#current_window_handle?? window_handles
newwin=driver.find_element_by_class_name('open')
newwin.click()
time.sleep(3)
current=driver.current_window_handle
allhandle=driver.window_handles
for hd in allhandle:
print hd
driver.switch_to_window(allhandle[1])
time.sleep(3)
driver.switch_to_window(allhandle[0])
def action():
el=driver.find_element_by_class_name('over')
ActionChains(driver).move_to_element(el).perform()
time.sleep(3)
el2=driver.find_element_by_id('over')
#print(el2.get_attribute('text'))
def wait():
driver.implicitly_wait(5)
driver.find_element_by_class_name('over')
WebDriverWait(driver??5).until(lambda driver:driver.find_element_by_class_name('open').is_displayed())
if __name__=='__main__':
wait()
??????????????????????????в?δ?漰???????????????????油???????