mirror of
https://dev.azure.com/Foster-X/CMP329%20CW2/_git/CMP329%20CW2
synced 2025-07-27 04:23:32 +00:00
added differentiation for different browsers
This commit is contained in:
parent
c3c1d218d6
commit
a60abd6fc3
1 changed files with 34 additions and 0 deletions
34
src/main/ConfigureDriver.java
Normal file
34
src/main/ConfigureDriver.java
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue