python自动打开edge浏览器

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.edge.service import Service

service = Service(executable_path=r'C:\Program Files (x86)\Microsoft\Edge\Application\msedgedriver.exe')
# 设置浏览器参数,让浏览器不自动关闭
option = webdriver.EdgeOptions()
option.add_experimental_option("detach", True)
# 设置浏览地址
driver = webdriver.Edge(service=service, options=option)
# 设置打开的网址
driver.get('http://127.0.0.1:8082/platform/login')
# 设置浏览器全屏显示
driver.maximize_window()
# 设置自动刷新
driver.refresh()
# 该元素的所有class都需要填写上
text_label = driver.find_element(By.XPATH, '//*[@class="form-control uname"]')
text_label.send_keys('admin')
text_label1 = driver.find_element(By.XPATH, '//*[@class="form-control pword"]')
text_label1.send_keys('admin123')
# 定位搜索按钮
button = driver.find_element(By.XPATH, '//*[@class="btn btn-success btn-block"]')
# 执行单击操作
button.click()

1.python 中获取元素最简单的方法:

本电脑模板:

button = driver.find_element(By.XPATH, '//*[@class="btn btn-success btn-block"]')

2.鼠标事件:

click()单击左键
context_click()单击右键
double_click()双击
drag_and_drop()拖动
move_to_element()鼠标悬停
perform()执行所有ActionChains中存储的动作
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值