最近Google Chrome推出了用于测试的Chrome浏览器,专门用于自动化。如何触发Chrome浏览器在robot框架中进行测试?
了解更多信息:https://googlechromelabs.github.io/chrome-for-testing/ 从 Chrome 114 版本开始,我们将不得不使用 Chrome 浏览器进行测试。 有人可以帮忙吗?
另外,浏览器在测试后自动关闭,我没有任何拆卸或关闭浏览器关键字。
有什么办法可以解决这个问题吗?
C:\opt\chrome_for_testing\chrome-win64
open browser browser=Chrome
options=binary_location=r"C:\\opt\\chrome_for_testing\\chrome-win64\\chrome.exe"
from robot.libraries.BuiltIn import BuiltIn
def start_chrome_for_testing_example():
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium import webdriver
opts = Options()
opts.add_argument("--no-sandbox")
opts.add_argument("--start-maximized")
opts.binary_location = r'C:\opt\chrome_for_testing\chrome-win64\chrome.exe'
chromedriver = r"C:\opt\chrome_for_testing\chromedriver-win64\chromedriver.exe"
browser = webdriver.Chrome(options=opts, service=Service(chromedriver))
selenium_library = BuiltIn().get_library_instance("SeleniumLibrary")
selenium_library._drivers.register(browser, 'chrome')```