简体   繁体   English

如何在 Azure 应用服务 (Linux) 上安装 ChromeDriver

[英]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 based or based.测试应基于 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.

相关问题 如何在 Linux Azure Web App 上安装和配置 Oracle Instant Client - How to install and configure Oracle Instant Client on a Linux Azure Web App 如何在Azure Web App Service Linux环境下安装自己的Python package? - How can I install my own Python package in Azure Web App Service Linux environment? 如何在 Azure function 应用程序中安装 python 模块 - How to install python modules in a Azure function app Azure 应用服务 linux 忽略自定义命令 - Azure app service linux custom command ignored 在 linux 上安装 azure 集成运行时并将数据从 Linux 移动到 Azure blob 存储 - Install azure integration runtime on linux and move data from Linux to Azure blob storage 如何在 AWS Linux 上安装 Skopeo? - How to install Skopeo on AWS Linux? 你如何在亚马逊 Linux 2 上安装 chrome? - How do you install chrome on Amazon Linux 2? 在 Azure 上使用 PM2 运行 nextjs 时出错 在 Linux 上应用服务 - Error running nextjs with PM2 on Azure App Service on Linux 使用 Linux 在 Azure App Service 上哪里可以找到 coredump? - Where to find coredump on Azure App Service using Linux? 在 Azure linux 应用程序服务上执行 sudo 命令作为启动的一部分 - Execute sudo commands as part of startup on Azure linux app service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM