Can you use Selenium with Java on Replit?

57 Views Asked by At

I have created a simple program using selenium to launch a web browser and navigate to a web page. I previously used BlueJ to run it locally, which works perfectly, but I need it to run every single week at a specific time. I got this to work using a timer task, but I was hoping to use Replit so that the program doesn't have to be open on my computer at all times. Here's a simple example of what i'm trying to run in replit:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.*;
import java.time.Duration;
import org.openqa.selenium.JavascriptExecutor;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.Calendar;

public class FitnessClassReservation extends TimerTask{
    public void run() {
        WebDriver driver = new ChromeDriver();
        try {
            driver.get("https://app.wodify.com/SignIn/Login?OriginalURL=&RequiresConfirm=false");
            driver.manage().window().maximize();
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(e);
        } finally {
            driver.quit();
        }
    }
    public static void main(String[] args) {
        Timer timer = new Timer();
        Calendar date = Calendar.getInstance();
        date.set(
                Calendar.DAY_OF_WEEK,
                Calendar.WEDNESDAY
        );
        date.set(Calendar.HOUR, 9);
        date.set(Calendar.MINUTE, 37);
        date.set(Calendar.SECOND, 0);
        date.set(Calendar.MILLISECOND, 0);
        timer.schedule(
                new FitnessClassReservation(),
                date.getTime(),
                1000
        );
    }
}

But it says that there is no package Selenium, and I can't find one that seems to work on replit's package manager. Also, I'm not sure if Timer Tasks work on replit either as when removing all the selenium code I couldn't get it to run. I'm fairly new to both Java and Replit, so if anyone has any ideas or knowledge I'd greatly appreciate it!

0

There are 0 best solutions below