第十期_Selenium 基础_20190725

参考资料

架构

安装

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

../venv/lib/python3.7/site-packages/selenium/webdriver/common/service.py:83: 

chromedriver

localhost:selenium seveniruby$ ./chromedriver
Starting ChromeDriver 75.0.3770.90 (a6dcaf7e3ec6f70a194cc25e8149475c6590e025-refs/branch-heads/3770@{#1003}) on port 9515
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.

GeckoDriver

localhost:selenium seveniruby$ ./geckodriver --help
geckodriver 0.24.0
WebDriver implementation for Firefox.

USAGE:
    geckodriver [FLAGS] [OPTIONS]

FLAGS:
        --connect-existing    Connect to an existing Firefox instance
    -h, --help                Prints help information
        --jsdebugger          Attach browser toolbox debugger for Firefox
    -v                        Log level verbosity (-v for debug and -vv for trace level)
    -V, --version             Prints version and copying information

OPTIONS:
    -b, --binary <BINARY>           Path to the Firefox binary
        --log <LEVEL>               Set Gecko log level [possible values: fatal, error, warn, info, config, debug, trace]
        --marionette-host <HOST>    Host to use to connect to Gecko (default: 127.0.0.1)
        --marionette-port <PORT>    Port to use to connect to Gecko (default: system-allocated port)
        --host <HOST>               Host ip to use for WebDriver server (default: 127.0.0.1)
    -p, --port <PORT>               Port to use for WebDriver server (default: 4444)

测试

from selenium import webdriver

def test_browser():
    browser = webdriver.Chrome()
    browser.get('https://testing-studio.com')

Selenium IDE

课间作业

  • 打开社区的第三个置顶帖,打开帖子,并点击帖子内的连接,租后断言预期界面的关键字是否存在, 把源代码贴到回复里