[英]How to install ChromeDriver on Azure app serveice (Linux)
I implemented Java code to scrape data using chromedriver.我使用 chromedriver 实现了 Java 代码来抓取数据。 My OS is Windows and the app service that I have is Linux. I put both chromedriver.exe (for windows) and chromedriver (for linux) in the resources folder.我的操作系统是 Windows,我拥有的应用程序服务是 Linux。我将 chromedriver.exe(适用于 Windows)和 chromedriver(适用于 linux)放在资源文件夹中。 I am able to run the code on Windows locally and it works but when I try to run the scraper on app service, it gives me an error as:我能够在本地运行 Windows 上的代码并且它可以工作但是当我尝试在应用程序服务上运行爬虫时,它给我一个错误:
lang.IllegalStateException: The driver executable does not exist: /src\main\resources\chromedriver
Code trials:代码试验:
System.setProperty("webdriver.chrome.driver", "src\\main\\resources\\chromedriver");
WebDriver driver = new ChromeDriver();
JavascriptExecutor js = (JavascriptExecutor) driver;
Is there a way that I can install/move the driver to a place in linux that I be able to run my code in Azure?有没有一种方法可以将驱动程序安装/移动到 linux 中的某个位置,以便我能够在 Azure 中运行我的代码?
As your OS is Windows and the app service is Linux based , keeping both chromedriver.exe (for windows) and chromedriver (for linux) in the resources folder isn't a recommended practice.由于您的操作系统是 Windows,而应用服务是基于 Linux 的,因此不推荐在资源文件夹中同时保留 chromedriver.exe(适用于 Windows)和 chromedriver(适用于 linux)。
Tests should be either windows based or linux based.测试应基于windows 或 linux 。 So only the optimum resources should only be shared within the resources
directory.所以只有最佳资源应该只在resources
目录中共享。
The bottom line is, if chromedriver.exe is not a part of your tests, you should totally remove it from the resources
directory and execute your tests with the recommended executables/libraries.底线是,如果chromedriver.exe不是您测试的一部分,您应该将其从resources
目录中完全删除,并使用推荐的可执行文件/库执行测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.