美文网首页
8、Selenium框架 — Remote

8、Selenium框架 — Remote

作者: 波罗的海de夏天 | 来源:发表于2020-04-27 09:12 被阅读0次

Selenium,Remote调用:

参考文档:https://www.jianshu.com/p/2ee251c81c1f

一、环境配置

  1. Selenium浏览器驱动
  1. JDK环境
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home
CLASSPAHT=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
PATH=$JAVA_HOME/bin:$PATH:
export JAVA_HOME
export CLASSPATH
export PATH
  • 确认配置是否成功:echo $JAVA_HOME

二、脚本测试Demo

# -*- coding:utf-8 -*-

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from threading import Thread
import time

def open_web(remote_name, remote_address, web_url):
    print('---- 启动: %s' % (remote_name))
    driver = webdriver.Remote(command_executor=remote_address, desired_capabilities=DesiredCapabilities.CHROME)
    driver.get(web_url)

    # 关闭浏览器
    time.sleep(5)
    driver.quit()


if __name__ == "__main__":
    data = {
        # 'linux': '',
        # 'windows': '',
        'localhost': 'http://localhost:4444/wd/hub'
    }
    web_url = 'https://baidu.com/'

    for name, address in data.items():
        print('---- name:{} address:{}'.format(name, address))
        # print('---- name:%s address:%s' % (name, address))
        # 多线程
        t = Thread(target=open_web, args=(name, address, web_url))
        t.start()
        # t.join()

三、终端检验接口是否联通

  • 检验网站或IP是否连通:
    ping www.baidu.com
    ping localhost
    ping http://localhost:4444/wd/hub
    ping 10.32.128.139

  • 检验端口是否连通:
    telnet 10.32.128.139 5328




相关文章

网友评论

      本文标题:8、Selenium框架 — Remote

      本文链接:https://www.haomeiwen.com/subject/cbbewhtx.html