UI自动化之复用浏览器 【调试脚本】

import time

from selenium.webdriver.common.by import By

'''
复用已有浏览器:配置步骤

1.需要退出当前所有的谷歌浏览器(特别注意)
    windows:关闭谷歌浏览器进程
2.输入启动命令,通过命令启动谷歌浏览器
windows: chrome --remote-debugging-port=9222
mac: Googlel\Chrome --remote-debugging-port=9222
    1.找到chrome的启动路径
    2.配置环境变量
3会证旦不户动成功

'''

from selenium.webdriver.chrome.options import Options
from selenium import webdriver

class TestDemo:
    def setup(self):
        # 定义配置的实例对象option
        option = Options()
        # 修改实例属性为debug模式启动的 ip+端口
        option.debugger_address = "localhost:9222"
        # 实例化driver的时候 添加option配置
        self.driver = webdriver.Chrome(options=option)
        self.driver.implicitly_wait(5)

    def teardown(self) -> None:
        pass
        # self.driver.quit()

    def test_case1(self):
        # 扫码登录后注释,后续操作在当前页面进行
        # self.driver.get("https://work.weixin.qq.com/wework_admin/frame")
        # time.sleep(15)
        #点击添加成员的操作
        # self.driver.find_element_by_css_selector('[class="ww_indexImg ww_indexImg_AddMember"]').click()

        #想要调试的代码
        self.driver.find_element(By.CSS_SELECTOR,"//*[id='username']").send_keys("admin")
        self.driver.find_element(By.ID,"memberAdd_acctid").send_keys('admin')
        time.sleep(5)

# # 定义配置的实例对象option
# # option = Options()
# # # 修改实例属性为debug模式启动的 ip+端口
# # option.debugger_address = "localhost:9222"
# # # 实例化driver的时候 添加option配置
# # driver = webdriver.Chrome(options=option)
# driver=webdriver.Chrome()
# driver.get("https://work.weixin.qq.com/wework_admin/frame")
# time.sleep(15)
# driver.find_element_by_css_selector('[class="ww_indexImg ww_indexImg_AddMember"]').click()
# time.sleep(5)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值