'Bitbucket pipeline cannot find chromedriver.exe even though it is in the same directory

I am getting this error:

FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver.exe'

However, chromedriver.exe is within the same file directory as bitbucket-pipelines.yml in my repo. This is how I'm using chromedriver.exe:

if __name__ == '__main__':
    s = Service("chromedriver.exe")
    driver = webdriver.Chrome(service=s)
    driver.maximize_window()
    ....

This python file is also within the same directory as chromedriver.exe and bitbucket-pipelines.yml. What am I doing wrong?

Edit bitbucket-pipeline.yml

- step:
        name: Get latest versions of libraries
        image: python:3.8.2
        script:
          - pip install selenium
          - pip install beautifulsoup4
          - pip install lxml
          - pip install webdriver-manager
          - python webscrape.py
        artifacts:
          - latest_vers.json



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source