This commit is contained in:
Lillian Violet 2024-03-05 10:59:55 +01:00
commit 4a1b080dda
3 changed files with 66 additions and 0 deletions

25
flake.lock Normal file
View file

@ -0,0 +1,25 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1709479366,
"narHash": "sha256-n6F0n8UV6lnTZbYPl1A9q1BS0p4hduAv1mGAP17CVd0=",
"rev": "b8697e57f10292a6165a20f03d2f42920dfaf973",
"revCount": 591063,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.591063%2Brev-b8697e57f10292a6165a20f03d2f42920dfaf973/018e0b39-3c52-71b1-81e1-d90220875f22/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/NixOS/nixpkgs/0.1.%2A.tar.gz"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

25
flake.nix Normal file
View file

@ -0,0 +1,25 @@
{
description = "A Nix-flake-based Python development environment";
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";
outputs = {
self,
nixpkgs,
}: let
supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
forEachSupportedSystem = f:
nixpkgs.lib.genAttrs supportedSystems (system:
f {
pkgs = import nixpkgs {inherit system;};
});
in {
devShells = forEachSupportedSystem ({pkgs}: {
default = pkgs.mkShell {
packages = with pkgs;
[python312 virtualenv geckodriver]
++ (with pkgs.python312Packages; [pip selenium]);
};
});
};
}

16
main.py Normal file
View file

@ -0,0 +1,16 @@
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
def gecko_test():
# Set the driver
driver = webdriver.Firefox()
driver.get("https://duck.com")
elem = driver.find_element(By.NAME, "q")
elem.send_keys("seleniumhq" + Keys.RETURN)
sleep(5)
driver.quit()
if __name__ == "__main__":
gecko_test()