• 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()
  • 相关阅读:
    Mysql中use filesort的误区
    Windows双系统
    Java visualvm
    软件设计师06-数据结构
    安装VMware14可能出现的问题
    计算机硬件系统
    Web漏洞扫描
    crunch制作字典
    kali之HexorBase数据库破解
    memcahce 介绍以及安装以及扩展的安装
  • 原文地址:https://www.cnblogs.com/drizzlewithwind/p/5073484.html
Copyright © 2020-2023  润新知