嘗試方法 -在衆多平臺快速通過腳本自動化驗證頁面兼容性,可以驗證pc,web ,android ,ios,驅動支持java,ruby,c#,python ,js

#test_baidu.py
import unittest
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys


class LTAutomate(unittest.TestCase):


def setUp(self):


# username: Username can be found at automation dashboard
username = "[email protected]"
accessToken = "PNyq3u1hemsDqX8WEgSA9uxSVusNVD02aoUV1anK9sLJtdCdtI"
gridUrl = "hub.lambdatest.com/wd/hub"

desired_cap = {

'platform':"Windows 10",
'browserName': "chrome",
'version': "67.0",
# Resolution of machine
"resolution": "1024x768",
"name": "name is baidu ",
"build": "test_build",
"network": True,
"video": True,
"visual": True,
"console": True,
}

# URL: https://{username}:{accessToken}@beta-hub.lambdatest.com/wd/hub
url = "https://" + username + ":" + accessToken + "@" + gridUrl

# print("Initiating remote driver on platfrom: " + desired_cap["platform"] + " browser: " + desired_cap[
# "browserName"] + " version: " + desired_cap["version"])
self.driver = webdriver.Remote(
desired_capabilities=desired_cap,
command_executor=url
)

def test_search_in_baidu(self):

driver = self.driver

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


time.sleep(4)
elem = driver.find_element_by_id("kw")
time.sleep(3)
elem.send_keys("123")
time.sleep(3)
click_test=driver.find_element_by_id('su').click()
time.sleep(2)


driver.execute_script("lambda-status=passed")

def tearDown(self):

self.driver.quit()


if __name__ == "__main__":
unittest.main()

#run python -m unittest test_baidu.py

效果圖:

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章