zoukankan      html  css  js  c++  java
  • python selenium基本

    基本

    from selenium import webdriver
    import re
    
    driver = webdriver.Firefox()
    driver.get('https://www.google.com')
    
    main_window = driver.current_window_handle
    
    driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't')
    
    element = driver.find_element_by_xpath("/html/body/div[2]/div[1]/table/tbody/tr[2]/td[6]")
    actions = ActionChains(driver)
    actions.move_to_element(element1)
    actions.perform()
    
    path = ‘/html/body/div[2]/div/ul/li/a'
    color_rgb = driver.find_element_by_xpath(path).value_of_css_property('color')
    rgb_values = re.match( r'w+((.*), (.*), (.*), d+)', color_rgb)
    red = rgb_values.group(1)
    green = rgb_values.group(2)
    blue = rgb_values.group(3)
    
    alert = driver.switch_to_alert()
    print alert.text
    required_text = "Login failed"
    if alert.text != required_text:
        print 'ERROR'
    alert.accept()
    
    while(driver.find_element_by_xpath("/html/body/div/form/div[1]/input").is_displayed()):
        driver.find_element_by_xpath("/html/body/div/form/div[1]/input").click()
    
    if not driver.find_element_by_id('checkitem').is_selected():
        driver.find_element_by_id('checkitem').click()
    
    driver.find_element_by_id('username').clear()
    
    key = driver.find_element_by_xpath('//tr[@class="dataView otr"][%d]/td[1]'%i).text.strip()
  • 相关阅读:
    前端安全
    关于HTTPS的概念性了解
    数组去重
    防抖与节流
    对meta标签的再次认识
    关于路由, 我好奇的那些点
    关于构造函数,实例,原型对象一纯手工的理解
    数据库查找操作-java
    python之图像加载和简单处理
    python之excel表格操作
  • 原文地址:https://www.cnblogs.com/drizzlewithwind/p/5073484.html
Copyright © 2011-2022 走看看