# coding:utf-8
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.select import Select
import time
driver=webdriver.Firefox()
driver.get("https://www.baidu.com")
time.sleep(10)
#打开搜索设置
mouse=driver.find_element_by_link_text("设置")
ActionChains(driver).move_to_element(mouse).perform()
driver.find_element_by_link_text("搜索设置").click()
time.sleep(10)
#通过索引定位:select_by_value(),设置为20每页
s=driver.find_element_by_id("nr")
Select(s).select_by_visible_text("每页显示50条")
#保存设置
driver.find_element_by_class_name("prefpanelgo").click()
#切换到alert弹出框上
t=driver.switch_to_alert()
#打印消息框中文本内容
print (t.text)
#点击“确认”按钮
t.accept()
#t.dismiss()