zoukankan      html  css  js  c++  java
  • selenium,unittest——下拉菜单操作,百度账号设置修改

    #encoding=utf-8
    from selenium import webdriver
    import time,unittest, re,sys
    from HTMLTestRunner import HTMLTestRunner
    from selenium.webdriver.common.action_chains import ActionChains
    '''
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.support.ui import Select
    from selenium.common.exceptions import NoSuchElementException
    from selenium.common.exceptions import NoAlertPresentException
    '''
    if sys.getdefaultencoding() != 'utf-8':
    reload(sys)
    sys.setdefaultencoding('utf-8')
    class Test(unittest.TestCase):
      '''百度登录'''
      @classmethod


      def setUpClass(self):
        self.driver=webdriver.Firefox()

        self.driver.get("http://www.baidu.com")
      time.sleep(10)
      def test_login(self):

        mouse = self.driver.find_element_by_link_text('设置')
        ActionChains(self.driver).move_to_element(mouse).perform()
        #调用ActionChains的方法时,会将所有的操作按顺序存放在一个队列里,调用perform()方法时,队列中的事件会依次执行
        self.driver.find_element_by_link_text('搜索设置').click()
        self.driver.find_element_by_link_text(u"保存设置").click()
        time.sleep(3)
        self.driver.switch_to.alert.accept()

      @classmethod
      def tearDownClass(self):
        self.driver.quit()
    if __name__=='__main__':
      unittest.main()

  • 相关阅读:
    spring-boot-mybatis-plus-layui 自定义代码生成完整多对一
    spring-boot-jap-layui-mysql 完整的jpa多对一
    IDEA 2020.1 热部署(JRebel)
    IDEA 2020.1 隐藏文件和文件夹
    IDEA 2020.1 修改代码字体和界面字体
    IDEA 2020.1 创建springboot项目(国内脚手架)安装lombok
    tensorflow2.0
    cuda资料收集
    视觉学习资料整理
    std::move and std::forward
  • 原文地址:https://www.cnblogs.com/garvicker/p/9952400.html
Copyright © 2011-2022 走看看