Reputation: 330
I am looking to use Selenium Chromedriver in an AWS Lambda function using C# but I am not having much luck... My initial error that i was getting was that "chromedriver.exe does not exist in /tmp/". Using the Webdrivermanager got me past this error but now i am having issues with permissions "Access to the path '/tmp/' is denied."
I have google my fingers off and have tried multiple ways of getting this to work. I bet it is something small that i am missing.
Any help would be greatly appreciated.
using System.Collections.Generic;
using Amazon.Lambda.Core;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using WebDriverManager;
public class Function
{
public void FunctionHandler(string input, ILambdaContext context)
{
var driver = GetDriver();
driver.Navigate().GoToUrl(input);
driver.Quit();
}
public IWebDriver GetDriver()
{
new DriverManager().SetUpDriver(
"http://chromedriver.storage.googleapis.com/75.0.3770.8/chromedriver_win32.zip",
"/tmp/",
"chromedriver.exe"
);
ChromeOptions options = new ChromeOptions();
options.AddArguments(new List<string>() {
"--no-sandbox",
"--headless",
"--disable-gpu",
"--homedir=/tmp"
});
return new ChromeDriver("/tmp/", options);
}
}
Upvotes: 2
Views: 2016
Reputation: 168092
Looking into AWS Lambda Runtimes page
Operating system – Amazon Linux
AMI – amzn-ami-hvm-2017.03.1.20170812-x86_64-gp2
Linux kernel – 4.14.77-70.59.amzn1.x86_64
So I believe you should be using the Linux Chromedriver, to wit replace this line:
http://chromedriver.storage.googleapis.com/75.0.3770.8/chromedriver_win32.zip
with this one:
https://chromedriver.storage.googleapis.com/75.0.3770.8/chromedriver_linux64.zip
and maybe chromedriver.exe
with just chromedriver
If you're going to invest into cloud-based web browser automation it might be easier to go for a specialized service like Saucelabs or Experitest
Upvotes: 2