欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python中Playwright模塊進(jìn)行自動(dòng)化測(cè)試的實(shí)現(xiàn)

 更新時(shí)間:2023年12月10日 09:59:18   作者:?cacho_37967865  
playwright是由微軟開發(fā)的Web UI自動(dòng)化測(cè)試工具,本文主要介紹了Python中Playwright模塊進(jìn)行自動(dòng)化測(cè)試的實(shí)現(xiàn),具有一定的參考價(jià)值,感興趣的可以了解一下

playwright是由微軟開發(fā)的Web UI自動(dòng)化測(cè)試工具,支持Node.js、Python、C# 和 Java語(yǔ)言,本文將介紹Python版本的Playwright使用方法。

微軟開源了一個(gè)非常強(qiáng)大的自動(dòng)化項(xiàng)目叫playwright-python,項(xiàng)目地址:https://github.com/microsoft/playwright-python 

它支持主流的瀏覽器,包含:Chrome、Firefox、Safari、Microsoft Edge 等,同時(shí)支持以無(wú)頭模式、有頭模式運(yùn)行,并提供了同步、異步的 API,可以結(jié)合 Pytest 測(cè)試框架使用,并且支持瀏覽器端的自動(dòng)化腳本錄制。

Playwright提供的自動(dòng)化技術(shù)是綠色的、功能強(qiáng)大、可靠且快速,支持Linux、Mac以及Windows操作系統(tǒng)。

官網(wǎng):https://playwright.dev/ 

從官網(wǎng)的解釋,官方給Playwright定位是一款真正意義上的Web端到端測(cè)試工具。

安裝步驟

第 1 步,安裝 playwright-python 依賴庫(kù) (需要注意的是,playwright庫(kù)需要依賴Python3.7+以上)

pip install -i https://mirrors.aliyun.com/pypi/simple/ --upgrade Playwright

第 2 步,安裝主流的瀏覽器驅(qū)動(dòng)

playwright install

如果想查看Playwright支持的功能, 可以直接在命令行輸入:playwright -h

使用Playwright可以無(wú)需寫代碼,只需手動(dòng)操作瀏覽器,它會(huì)錄制我們的操作,然后自動(dòng)生成代碼腳本。

錄制腳本

1. 查看錄制命令說(shuō)明 playwright codegen -h

Usage: playwright codegen [options] [url]

open page and generate code for user actions

Options:
  -o, --output <file name>             saves the generated script to a file
  --target <language>                  language to generate, one of javascript, playwright-test, python, python-async,
                                       python-pytest, csharp, csharp-mstest, csharp-nunit, java (default: "python")
  --save-trace <filename>              record a trace for the session and save it to a file
  --test-id-attribute <attributeName>  use the specified attribute to generate data test ID selectors
  -b, --browser <browserType>          browser to use, one of cr, chromium, ff, firefox, wk, webkit (default:
                                       "chromium")
  --block-service-workers              block service workers
  --channel <channel>                  Chromium distribution channel, "chrome", "chrome-beta", "msedge-dev", etc
  --color-scheme <scheme>              emulate preferred color scheme, "light" or "dark"
  --device <deviceName>                emulate device, for example  "iPhone 11"
  --geolocation <coordinates>          specify geolocation coordinates, for example "37.819722,-122.478611"
  --ignore-https-errors                ignore https errors
  --load-storage <filename>            load context storage state from the file, previously saved with --save-storage
  --lang <language>                    specify language / locale, for example "en-GB"
  --proxy-server <proxy>               specify proxy server, for example "http://myproxy:3128" or
                                       "socks5://myproxy:8080"
  --proxy-bypass <bypass>              comma-separated domains to bypass proxy, for example
                                       ".com,chromium.org,.domain.com"
  --save-har <filename>                save HAR file with all network activity at the end
  --save-har-glob <glob pattern>       filter entries in the HAR by matching url against this glob pattern
  --save-storage <filename>            save context storage state at the end, for later use with --load-storage
  --timezone <time zone>               time zone to emulate, for example "Europe/Rome"
  --timeout <timeout>                  timeout for Playwright actions in milliseconds, no timeout by default
  --user-agent <ua string>             specify user agent string
  --viewport-size <size>               specify browser viewport size in pixels, for example "1280, 720"
  -h, --help                           display help for command

Examples:

  $ codegen
  $ codegen --target=python
  $ codegen -b webkit https://example.com

比如,我要在baidu.com搜索,用chromium驅(qū)動(dòng),將結(jié)果保存為test.py的python文件。文檔默認(rèn)保存到 C:\Users\user\下面

playwright codegen --target python -o 'test.py' -b chromium https://www.baidu.com

到此這篇關(guān)于Python中Playwright模塊進(jìn)行自動(dòng)化測(cè)試的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Python Playwright自動(dòng)化測(cè)試內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 全網(wǎng)最詳細(xì)的PyCharm+Anaconda的安裝過程圖解

    全網(wǎng)最詳細(xì)的PyCharm+Anaconda的安裝過程圖解

    這篇文章主要介紹了全網(wǎng)最詳細(xì)的PyCharm+Anaconda的安裝過程圖解,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-01-01
  • 基于Python實(shí)現(xiàn)模擬三體運(yùn)動(dòng)的示例代碼

    基于Python實(shí)現(xiàn)模擬三體運(yùn)動(dòng)的示例代碼

    此前所做的一切三體和太陽(yáng)系的動(dòng)畫,都是基于牛頓力學(xué)的,而且直接對(duì)微分進(jìn)行差分化,從而精度非常感人,用不了幾年就得撞一起去。所以本文來(lái)用Python重新模擬一下三體運(yùn)動(dòng),感興趣的可以了解一下
    2023-03-03
  • python 如何用map()函數(shù)創(chuàng)建多線程任務(wù)

    python 如何用map()函數(shù)創(chuàng)建多線程任務(wù)

    這篇文章主要介紹了python 使用map()函數(shù)創(chuàng)建多線程任務(wù)的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧
    2021-04-04
  • Python中的迭代器你了解嗎

    Python中的迭代器你了解嗎

    迭代器是一種特殊的對(duì)象,它實(shí)現(xiàn)了迭代協(xié)議,允許按照一定的順序逐個(gè)訪問元素,本文就來(lái)帶大家深入了解一下Python中迭代器的使用,需要的可以參考下
    2023-05-05
  • Python實(shí)現(xiàn)排序算法、查找算法和圖遍歷算法實(shí)例

    Python實(shí)現(xiàn)排序算法、查找算法和圖遍歷算法實(shí)例

    這篇文章主要介紹了Python實(shí)現(xiàn)排序算法、查找算法和圖遍歷算法實(shí)例,排序算法、查找算法和圖遍歷算法是計(jì)算機(jī)科學(xué)中常見且重要的算法。它們?cè)跀?shù)據(jù)處理、搜索和圖結(jié)構(gòu)等領(lǐng)域發(fā)揮著關(guān)鍵作用,需要的朋友可以參考下
    2023-08-08
  • python?如何求N的階乘

    python?如何求N的階乘

    這篇文章主要介紹了python?如何求N的階乘,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-05-05
  • 初探TensorFLow從文件讀取圖片的四種方式

    初探TensorFLow從文件讀取圖片的四種方式

    本篇文章主要介紹了初探TensorFLow從文件讀取圖片的四種方式,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧
    2018-02-02
  • 使用Python繪制可愛的招財(cái)貓

    使用Python繪制可愛的招財(cái)貓

    招財(cái)貓,也被稱為“幸運(yùn)貓”,是一種象征財(cái)富和好運(yùn)的吉祥物,經(jīng)常出現(xiàn)在亞洲文化的商店、餐廳和家庭中,今天,我將帶你用 Python 和 matplotlib 庫(kù)從零開始繪制一只可愛的卡通招財(cái)貓,感興趣的小伙伴跟著小編一起來(lái)看看吧
    2025-01-01
  • python?plotly設(shè)置go.Scatter為實(shí)線實(shí)例

    python?plotly設(shè)置go.Scatter為實(shí)線實(shí)例

    這篇文章主要為大家介紹了python?plotly設(shè)置go.Scatter為實(shí)線線條的樣式實(shí)例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-10-10
  • python 實(shí)現(xiàn)字符串下標(biāo)的輸出功能

    python 實(shí)現(xiàn)字符串下標(biāo)的輸出功能

    這篇文章主要介紹了python 簡(jiǎn)單的實(shí)現(xiàn)字符串下標(biāo)的輸出,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-02-02

最新評(píng)論