zoukankan      html  css  js  c++  java
  • 常用定位元素的方法练习(一)

    from selenium import webdriver
    import os

    #编写tapd提交bug登录的脚本
    #1.通过id定位元素
    current_path=os.path.dirname(__file__)
    print(current_path)
    wbdriver_path=os.path.join(current_path,'../webdriver/chromedriver.exe')
    print(wbdriver_path)
    driver=webdriver.Chrome(executable_path=wbdriver_path) #加载驱动
    driver.get('https://www.tapd.cn/cloud_logins/login') #打开登录地址
    driver.maximize_window()
    driver.implicitly_wait(30)
    driver.find_element_by_id('username').send_keys('tingting.yang@juneyaokc.com11') #输入用户名
    driver.find_element_by_id('password_input').send_keys('ytt1234561..') #输入密码
    driver.find_element_by_id('tcloud_login_button').click() #点击登录按钮
    driver.quit() #关闭浏览器

    from selenium import webdriver
    import os

    #编写tapd提交bug登录的脚本
    #1.通过name定位元素
    current_path=os.path.dirname(__file__)
    print(current_path)
    wbdriver_path=os.path.join(current_path,'../webdriver/chromedriver.exe')
    print(wbdriver_path)
    driver=webdriver.Chrome(executable_path=wbdriver_path) #加载驱动
    driver.get('https://www.tapd.cn/cloud_logins/login') #打开登录地址
    driver.maximize_window()
    driver.implicitly_wait(30)
    driver.find_element_by_name('data[Login][email]').send_keys('tingting.yang@juneyaokc.com1') #输入用户名
    driver.find_element_by_name('data[Login][password]').send_keys('ytt1234561..') #输入密码
    driver.find_element_by_id('tcloud_login_button').click() #点击登录按钮
    driver.quit() #关闭浏览器

    from selenium import webdriver
    import os

    #编写tapd提交bug登录的脚本
    #3.通过xpass定位元素
    current_path=os.path.dirname(__file__)
    print(current_path)
    wbdriver_path=os.path.join(current_path,'../webdriver/chromedriver.exe')
    print(wbdriver_path)
    driver=webdriver.Chrome(executable_path=wbdriver_path) #加载驱动
    driver.get('https://www.tapd.cn/cloud_logins/login') #打开登录地址
    driver.maximize_window()
    driver.implicitly_wait(30)
    driver.find_element_by_xpath('/html/body/div/form/div[2]/div/input').send_keys('tingting.yang@juneyaokc11.com') #输入用户名
    driver.find_element_by_xpath('/html/body/div/form/div[3]/div/input').send_keys('ytt1234561..') #输入密码
    driver.find_element_by_xpath('/html/body/div/form/div[4]/input').click() #点击登录按钮
    driver.quit() #关闭浏览器

    #编写tapd提交bug登录的脚本
    #4.通过css定位元素
    current_path=os.path.dirname(__file__)
    print(current_path)
    wbdriver_path=os.path.join(current_path,'../webdriver/chromedriver.exe')
    print(wbdriver_path)
    driver=webdriver.Chrome(executable_path=wbdriver_path) #加载驱动
    driver.get('https://www.tapd.cn/cloud_logins/login') #打开登录地址
    driver.maximize_window()
    driver.implicitly_wait(30)
    driver.find_element_by_css_selector('input#username').send_keys('tingting.yang@juneyaokc11.com') #输入用户名
    driver.find_element_by_css_selector('input#password_input').send_keys('ytt12345611..') #输入密码
    driver.find_element_by_css_selector('input#tcloud_login_button').click() #点击登录按钮
    driver.quit() #关闭浏览器

  • 相关阅读:
    MySQL 索引相关
    MySQL 事务操作
    MySQL 分支循环
    详细实例教程!集成华为虚假用户检测,防范虚假恶意流量
    快速集成华为AGC云存储服务-NodeJS
    随心译——无广告的专属实时翻译神器
    如何实现情景式精准触达用户,提高用户活跃与转化?
    快速集成华为AGC-AppLinking服务-iOS平台
    华为联运游戏或应用审核驳回:点击登录进入游戏,未显示欢迎栏
    视频App如何使用无线传输服务获得更好的播放体验
  • 原文地址:https://www.cnblogs.com/tingting-yang/p/13254692.html
Copyright © 2011-2022 走看看