如何在我的Cucumber代码中指定安装在Jenkins内部的chromedriver路径?

huangapple 未分类评论47阅读模式
英文:

How to specify the chromedriver path which is installed inside jenkins in my cucumber code?

问题

已在Jenkins中安装了Chromedriver插件,现在我需要在我的代码中指定路径,该如何操作?当我在本地系统中有驱动程序时,我可以这样做:

System.setProperty("webdriver.chrome.driver", "C:\\Soumen\\Softwares\\chromedriver.exe");

但在Jenkins的情况下,应该如何操作?

英文:

I have installed Chromedriver plugin in my Jenkins, now I need to specify the path inside my code , how can I do that? When I have the driver in my local system I can do it

System.setProperty("webdriver.chrome.driver","C:\\Soumen\\Softwares\\chromedriver.exe");

but in case of Jenkins how to do it?

答案1

得分: 0

为了彻底解决这个问题,您可以使用这个库"webdrivermanager"来下载驱动,而不是将它保存在您的本地文件系统中。

您还可以像这样在程序中选择版本:
WebDriverManager.chromedriver().version("77.0.3865.40").setup();

英文:

To completely mitigate this problem you can use this library "webdrivermanager"
to download the driver instead of having it in your local file system

and you can choose the version programmatically like that:
WebDriverManager.chromedriver().version("77.0.3865.40").setup();

答案2

得分: 0

driver = webdriver.Chrome(executable_path=r"C:\Users\ANISH JAIN\Documents\PYTHON_PROGRAMME\chromedriver.exe")
and then use driver to do everything

英文:

driver = webdriver.Chrome(executable_path=r"C:\Users\ANISH JAIN\Documents\PYTHON_PROGRAMME\chromedriver.exe")
and then use drive to do everthing

huangapple
  • 本文由 发表于 2020年4月8日 20:10:41
  • 转载请务必保留本文链接:https://java.coder-hub.com/61100361.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定