RobotFramework_SeleniumLibrary_Browser 已启动但提到的 URL 未导航至

问题描述 投票:0回答:1

我是使用 SeleniumLibrary 的 Robotframework Web Automation 的初学者。我试图编写一个简单的机器人测试用例来启动 Chrome 浏览器并导航到 www.google.com。 我正在使用 Pycharm IDE。 Python 版本为 3.7.5,Robot Framework 为 3.1.2,Selenium 3.141.0。此外,Pycharm 中还添加了所需的包,如 RobotFramework、Selenium、RobotFramework-SeleniumLibrary 包,Pycharm 中也添加了 Intellibot 插件。 chrome 浏览器版本是 112.0.5615.121,下载的最匹配的 ChromeDriver 是 112.0.5615.49,这个 .exe 保存在 Python37 文件夹下的 Scripts 文件夹中,Env variables Path 中提供了相同的路径。 下面是我的代码。

*** Settings ***
Library    SeleniumLibrary

*** Test Cases ***

Testcase name: Launch and Navigate:
        open browser    www.google.com      chrome

当我运行这个测试时,chrome 浏览器启动了,但在 URL 中,它显示了这个 - “数据:”,并且毫无保留地停留在那里。如果我在这个阶段关闭浏览器,在 Pycharm 终端中获取以下错误详细信息:

WebDriverException: Message: unknown error: Chrome failed to start: exited normally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location C:\Program Files (x86)\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

有人可以让我知道这是由于配置/设置问题还是代码解决问题造成的吗?我在我的客户端远程桌面上执行此操作。

Output

出于同样的目的,我也尝试了以下代码:

*** Settings ***

Library    SeleniumLibrary

*** Variables ***

${url}      https://www.google.com
${driver_path}      C:/Program Files/Python37/Scripts/chromedriver


*** Test Cases ***
TC_01Launch

        ${chrome_options}=  Evaluate  sys.modules['selenium.webdriver'].ChromeOptions()  sys, selenium.webdriver

        Call Method    ${chrome_options}    add_argument    --no-sandbox
        Create Webdriver  Chrome    executable_path=${driver_path}      
        Open Browser    ${url}    chrome        options=${chrome_options}
selenium-webdriver selenium-chromedriver robotframework
1个回答
0
投票

我们还需要用 URL 指定协议(http:// 或 https://)。在你的情况下,尝试:

open browser  https://www.google.com  chrome
© www.soinside.com 2019 - 2024. All rights reserved.