简体   繁体   English

没有使用机器人框架安装边缘驱动程序

[英]edge driver is not getting installed using robotframework

We are using Python robot framework automation.我们正在使用 Python 机器人框架自动化。 Is it possible to download and install edge driver automatically while script run based on the version passed as parameter?We are using selenium 3.14, robot framework selenium library 4.5.0 and python 3.7是否可以在脚本运行时根据作为参数传递的版本自动下载和安装边缘驱动程序?我们使用的是 selenium 3.14,机器人框架 selenium 库 4.5.0 和 Z23EEEB4347BDD26BFC6B7EE9A3B75。

No, that is not possible.不,那是不可能的。 Installation of any webdriver must be done before running tests, because it requires to have prepared the environment variable PATH and proper execution permissions for the webdriver.任何 webdriver 的安装都必须在运行测试之前完成,因为它需要为 webdriver 准备好环境变量 PATH 和适当的执行权限。

Is it possible to download and install edge driver automatically while script run based on the version passed as parameter?是否可以根据作为参数传递的版本在脚本运行时自动下载和安装边缘驱动程序?

Answer- YES答案 - 是的

For that you need to install driver manager using - pip install webdriver-manager为此,您需要使用 - pip install webdriver-manager安装驱动程序管理器

Then use the below imports -然后使用以下导入 -

from selenium import webdriver
from webdriver_manager.microsoft import EdgeChromiumDriverManager

You can use the python function as keyword in robot framework something like given below.您可以使用 python function 作为机器人框架中的关键字,如下所示。 Where 96.0.1054.43 parameter is the version of edge driver.其中96.0.1054.43参数是边缘驱动程序的版本。 And this function is written in lets say - drivermanager.py file.而这个 function 是写在可以说 - drivermanager.py文件中的。

def get_chromedriver_path():
    driver_path = EdgeChromiumDriverManager("96.0.1054.43").install()
    print(driver_path)
    return  driver_path

You can import this( drivermanager.py ) library in your testsuite using command - Library drivermanager.py .您可以使用命令Library drivermanager.py在您的测试套件中导入这个( drivermanager.py )库。 This function will be treated as keyword when executed.这个 function 在执行时将被视为关键字。

Testsuite will have testcase as测试套件将测试用例作为

Open Chrome Browser
    [Documentation]      To create chrome browser instance with specific profile

    ${chromedriver_path}=   drivermanager.Get Chromedriver Path

Here ${chromedriver_path} variable holds the driver path.这里${chromedriver_path}变量保存驱动程序路径。 and the driver stored in the cache.以及存储在缓存中的驱动程序。

Screenshot of Executions -执行截图 -

在此处输入图像描述

References - 1. https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ 2. https://github.com/SergeyPirogov/webdriver_manager参考资料 - 1. https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ 2. https://github.com/SergeyPirogov/webdriver_manager

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM