Python Selenium how to use Firefox

Question:
How do I use firefox in selenium on replit instead of chrome? I had to add packages manually for chrome, but cannot find the package names for firefox.

https://replit.com/@NathanaelMoore1/ServerAutomation?v=1


#This script uses Selenium to load a server voting website, and votes for EternallyBlue445. Change the 'EternalyBlue455' to your minecraft username and the planetminecraft link to your server voting site to adapt it for yourself.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import time

ONE_DAY = 24 * 60 * 60  # seconds

x = 0
i = 0

while x == 0:
	# I don't actually know what this stuff does.
	chrome_options = Options()
	chrome_options.add_argument('--no-sandbox')
	chrome_options.add_argument('--disable-dev-shm-usage')
	
	# This is Google Chrome. Shoved into a variable called 'driver'
	driver = webdriver.Chrome(options=chrome_options)
	
	# Change the link to your server's vote site.
	print("Loading site...")
	driver.get("https://www.planetminecraft.com/server/the-stoned-golem/vote/")
	
	# This makes the text box for the Minecraft username into a variable that we can work with.
	print("Finding text box...")
	name_txt_box = driver.find_element(By.NAME, 'mcname')
	
	# Change the string to your Minecraft username.
	print("Typing userame...")
	name_txt_box.send_keys('EternallyBlue445')
	
	# This submits the form, sending your vote.
	print("Submitting...")
	name_txt_box.submit()

	# Closes browser.
	print("Closing browser...")
	driver.close()
	
	# Counting how many times the code has run.
	i+=1
	print("Done!", i)

	# Records the number of runs the script has made and puts the record into "data.txt"
	f = open("data.txt", "a")
	f.write(str(i) + "\n")
	f.close()

	# Lets the script sleep for 1 day
	time.sleep(ONE_DAY)

print("The script failed after " + i + " runs.")

The Replit.Nix packages:

{ pkgs }: {
  deps = [
		pkgs.chromium
		pkgs.chromedriver
		pkgs.sudo
    pkgs.python310Full
    pkgs.replitPackages.prybar-python310
    pkgs.replitPackages.stderred
  ];
1 Like

It’s crazy; this was 7 months ago. Anyway, I just wanted to mention that I don’t use chromedriver; I just use Playwright. It’s easier and faster

2 Likes