日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python运维脚本部署jdk_基于Java/Python搭建Web UI自动化环境

發布時間:2023/12/2 python 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python运维脚本部署jdk_基于Java/Python搭建Web UI自动化环境 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Java搭建UI自動化測試環境

下載JDK8

https://www.cnblogs.com/thloveyl/p/12378124.html

配置Java環境

1.解壓Jdk壓縮包

2.配置環境變量

計算機->屬性->高級->環境變量->系統變量->Path

3.添加根目錄下的bin與lib目錄、jre下的bin目錄(近期我發現只將bin目錄加入Path就可以了)

{% asset_img 2.PNG %}

注:都是目錄下絕對路徑地址,我這兒在E盤。

4.輸入java、javac、java -version確認

下載selenium server

安裝對應版本的Chrome瀏覽器驅動

IDEA導入jar包

File->Project Settings->Modules->Dependencies->‘+‘->JARS...

選中之后點ok->勾上jar包->applay->ok

實例

package com.smeoa.UI;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeOptions;

import org.openqa.selenium.chrome.ChromeDriver;

public class DemoChromeDriver

{

public static void main(String[] args) throws Exception

{

//設置瀏覽器的驅動屬性、值。

System.setProperty("webdriver.chrome.driver","D:\\Driver\\chromedriver.exe");

//取消 chrome正受到自動測試軟件的控制的信息欄

ChromeOptions options = new ChromeOptions();

options.addArguments("disable-infobars");

//實例化Driver對象

WebDriver driver = new ChromeDriver(options);

//打開網址:在url欄輸入https://www.baidu.com

driver.get("http://www.baidu.com");

//xpath元素定位:輸入欄,sendKeys輸入Java

driver.findElement(By.xpath("/html//input[@id='kw']")).sendKeys("github");

//點擊百度一下

driver.findElement(By.xpath("/html//input[@id='su']")).click();

Thread.sleep(100);

//關閉瀏覽器

driver.close();

}

}

Python搭建UI自動化環境

下載Python3

環境配置

安裝Python

勾選Add Python to PATH,一直下一步。

驗證:CMD輸入Python

下載Chrome Driver

安裝PyCharm

安裝Selenium

打開PyCharm

新建Python File

點擊面板底部 Terminal

輸入pip install selenium 安裝、pip list 驗證

實例

from selenium import webdriver

# 設置 :忽略正在受自動測試軟件的控制

option = webdriver.ChromeOptions()

option.add_argument('disable-infobars')

# 實例化 對象

driver = webdriver.Chrome(chrome_options=option)

# 打開網址

driver.get("https://www.baidu.com")

# 通過id元素定位到輸入框,輸入github

driver.find_element_by_id("kw").send_keys("github")

# 點擊百度一下

driver.find_element_by_id("su").click()

driver.close()

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的python运维脚本部署jdk_基于Java/Python搭建Web UI自动化环境的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。