added differentiation for different browsers

This commit is contained in:
Xander 2025-04-02 16:56:51 +01:00
parent c3c1d218d6
commit a60abd6fc3

View file

@ -0,0 +1,34 @@
package main;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
public class ConfigureDriver {
public static WebDriver ConfigureDriver() {
WebDriver driver;
String filePath = ".user"; // Ensure the file exists in the working directory
String user = "";
try {
user = Files.readString(Paths.get(filePath)).trim();;
System.out.println("User read: " + user);
} catch (IOException e) {
System.err.println("Error reading user file: " + e.getMessage());
}
if (user == "xander") {
System.setProperty("webdriver.gecko.driver", "/usr/local/bin/geckodriver");
FirefoxOptions options = new FirefoxOptions();
options.setBinary("/usr/bin/firefox"); // Explicitly set Firefox binary
driver = new FirefoxDriver(options);
}
else {
/// DREW ADD YOUR WEB DRIVER CODE PLEASE
}
return driver;
}
}