IDEA+Python+Selenium+360浏览器自动化测试

  1. 环境配置前提,见文章https://mp.csdn.net/mp_blog/creation/editor/new?spm=1001.2101.3001.4503

  1. 下载360浏览器,并下载对应版本的chromedriver.exe,下载地址http://chromedriver.storage.googleapis.com/index.html

  1. 下载好360浏览器,将chromedriver.exe放在D:\Python\Python311\chromedriver.exe,以便使用

  1. 以下是使用360浏览器实现selenium自动化的前提

from selenium import webdriver

from selenium.webdriver.chrome.service import Service

from selenium.webdriver.common.by import By

import time

options=webdriver.ChromeOptions()

options.binary_location=r'D:\Program Files\360\360se6\Application\360se.exe'#360浏览器安装地址

service=Service(r'D:\Python\Python311\chromedriver.exe')#谷歌浏览器chromedriver.exe地址

driver=webdriver.Chrome(service=service,options=options)#需要定义Service,否则会报错

driver.get("http://198.23.23.33:9020/")

driver.find_element(by=By.ID,value='USERID').send_keys("406149")

driver.find_element(by=By.ID,value='PASSWORD_VIEW').send_keys("222222")

time.sleep(3000)

driver.close()

注意:

Traceback (most recent call last):

File "C:\Users\ogin.py", line 2, in <module>

driver =webdriver.Chrome();https://registry.npmmirror.com/binary.html?path=chromedriver/

如果执行过程中报以上错误,有可能是chromedriver.exe不兼容问题,下载对应的chromedriver.exe即可,地址见第2步

猜你喜欢

转载自blog.csdn.net/u012388338/article/details/129366476