Issue
My problem is Firefox. I installed a different location. But I tried this solution isn't working for me.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxProfile;
import java.io.File;
public class firefoxDriver
{
public static void main(String[] args)
{
File pathBinary = new File("D:\\Program Files\\Mozilla Firefox\\firefox.exe");
FirefoxBinary ffBinary = new FirefoxBinary(pathBinary);
FirefoxProfile ffProfile = new FirefoxProfile();
// Add .exe file
System.setProperty("webdriver.gecko.driver", "D:\\Docs\\Drivers\\geckodriver.exe");
// Create Firefox object driver.
WebDriver ffDriver = new FirefoxDriver(ffBinary, ffProfile);
ffDriver.get("https://google.com");
System.out.println(ffDriver.getTitle());
}
}
Solution
public static void main(String[] args)
{
// Add .exe file
System.setProperty("webdriver.gecko.driver", "D:\\Docs\\Drivers\\geckodriver.exe");
File pathBinary = new File("D:\\Program Files\\Mozilla Firefox\\firefox.exe");
FirefoxBinary ffBinary = new FirefoxBinary(pathBinary);
DesiredCapabilities desired = DesiredCapabilities.firefox();
FirefoxOptions ffOptions = new FirefoxOptions();
desired.setCapability(FirefoxOptions.FIREFOX_OPTIONS, ffOptions.setBinary(ffBinary));
// Create Firefox object driver.
WebDriver ffDriver = new FirefoxDriver(ffOptions);
ffDriver.get("https://google.com");
System.out.println(ffDriver.getTitle());
}
I solved my problem with this method. I don't know there is a much more simple solution.
Answered By - Yekta Özdemir
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.