# How to implement "Selenium" using python

**URL:** <https://community.firebasestudio.dev/t/how-to-implement-selenium-using-python/1443>\
**Category:** General\
**Created:** [August 14, 2024, 9:24am UTC](https://community.firebasestudio.dev/t/how-to-implement-selenium-using-python/1443 "2024-08-14T09:24:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Swaroop](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/swaroop/32/931_2.png) [@Swaroop](https://community.firebasestudio.dev/u/Swaroop)\
**Post date:** [August 14, 2024, 9:24am UTC](https://community.firebasestudio.dev/t/how-to-implement-selenium-using-python/1443/1 "2024-08-14T09:24:11Z")

</div>

I have installed “selenium” using the terminal, but I am unable to run the below code successfully. I am getting the error: WebDriverException

I am using .venv kernel  
If it is an issue with the ChromeDriver then please give me the steps to solve this problem.

from selenium import webdriver  
from selenium.webdriver.common.keys import Keys  
from selenium.webdriver.common.by import By  
import time

driver = webdriver.Chrome()  
driver.get(“[http://www.python.org](http://www.python.org)”)  
assert “Python” in driver.title  
elem = driver.find\_element(By.NAME, “q”)  
elem.clear()  
elem.send\_keys(“pycon”)  
elem.send\_keys(Keys.RETURN)  
assert “No results found.” not in driver.page\_source  
time.sleep(6)  
driver.close()

---

<div class="post-metadata">

**Author:** ![alice](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/alice/32/1234_2.png) [@alice](https://community.firebasestudio.dev/u/alice)\
**Post date:** [August 15, 2024, 12:08am UTC](https://community.firebasestudio.dev/t/how-to-implement-selenium-using-python/1443/2 "2024-08-15T00:08:16Z")

</div>

Sadly I could not make Chrome WebDriver work either, but using Firefox WebDriver works, I wrote this flake.nix file because stable-24.05 and unstable channels are outdated making firefox and geckodriver be incompatibles [at least that happened in my workspace].

```auto
{
  description = "Selenium Environment";

  inputs = {
    # using nixos-unstable because geckodriver is outdated in nixos-24.05
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:    
      let
        pkgs = import nixpkgs { inherit system; };
      in
      with pkgs;
      {
        devShells.default = mkShell {        
          buildInputs = [firefox geckodriver];

          # Somehow VSCode terminal pops up with "bash: __vsc_prompt_cmd_original: command not found"
          shellHook = ''
            unset PROMPT_COMMAND
          '';
        };
      }
    );
}

```

and respectively using the firefox driver in the Python code:

```python
options = webdriver.FirefoxOptions()
# required for idx.dev because no user interface is available
options.add_argument('--headless')
driver = webdriver.Firefox(options=options)

```

Otherwise we will have to wait for some solution If you really want to use the Chrome Web Driver.

---

<div class="post-metadata">

**Author:** ![Sunny](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/sunny/32/85_2.png) [@Sunny](https://community.firebasestudio.dev/u/Sunny)\
**Post date:** [August 22, 2024, 8:40pm UTC](https://community.firebasestudio.dev/t/how-to-implement-selenium-using-python/1443/3 "2024-08-22T20:40:56Z")

</div>

Have you tried using chromium-headless?
