2

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);
    }
}

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

4 Comments

@Dmitiri T Thank you for this... It did move me past this problem so it is correct. However i am now getting permission errors when trying to access the chrome driver. At this point 'return new ChromeDriver("/tmp/", options);'
@MitchellStone Hello. Did you by chance get anywhere with this? Thanks :)
@ZachOverflow Dmitri was right, the back end of Lambda functions is Linux based, so you need the Linux version of the driver. We ended up not using Lambda, the driver is to large to upload with any other libraries so it was going to have to be downloaded with each Lambda execution, which did not suit.
@MitchellStone Thanks all for the help. I'm going to try & hack Lambda to see if it's possible, but for now I'm looking to run our automated tests in a Container service - I'm keen on Amazon ECS with Fargate. I'm hoping I will be able to programmatically spin up containers etc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.