python 爬虫 元素交互

import time

from selenium import webdriver
from selenium.webdriver.firefox.options import Options as FOptions

options=FOptions()

browser=webdriver.Firefox(executable_path="/Users/mac126/geckodriver",firefox_options=options)


#元素交互

browser.get('https://mail.163.com/')
time.sleep(2)
text1=browser.find_element_by_css_selector('#normalLoginTab > div > div > iframe')
browser.switch_to.frame(text1)
result=browser.find_element_by_xpath('//input[@class="j-inputtext dlemail"]')
result.send_keys('123')

# browser.get('https://mail.163.com/')
# time.sleep(2)
#

 

posted @ 2018-12-26 10:15  青春叛逆者  阅读(236)  评论(0编辑  收藏  举报