I've been working on a login with facebook feature on my java program. I am following this tutorial.
In this tutorial, it needs to include a chromedriver to a specific project folder in order to open Facebook login page. Since I am using captain casa framework, I wasn't able to do it. It gives me an error
java.lang.IllegalStateException: The driver executable does not exist: C:\EnterpriseClientRISC\server\chromedriver.exe
But I am not allowed to put the chrome there.
Is there any alternative way to popup facebook login page into another window without using chromedriver?
I saw other tutorial combining javascript, but I am not allowed to do it in my captain casa framework.
Here's my code>
try {
Statusbar.outputSuccessWithPopup("before anything else").setLeftTopReferenceCentered();
String domain = "https://dev-ecom.partnersbusiness.solutions/";
String appId = "1830823116979050";
String authUrl = "https://graph.facebook.com/oauth/authorize?type=user_agent&client_id="+appId+"&redirect_uri="+domain+"&scope=user_about_me,ads_management, ads_read email, pages_manage_cta, pages_show_list";
//TODO SET CHROMEDRIVER HERE
setNewProperty("webdriver.chrome.driver", "chromedriver.exe");
WebDriver driver = new ChromeDriver() {
};
driver.get(authUrl);
String accessToken;
Statusbar.outputSuccessWithPopup("before while").setLeftTopReferenceCentered();
//Note, wa kaabot after sa login here
while (true){
if (!driver.getCurrentUrl().contains("facebook.com")) {
String url = driver.getCurrentUrl();
accessToken = url.replaceAll(".*#access_token=(.+)&.*", "$1");
driver.quit();
FacebookClient fbClient = new DefaultFacebookClient(accessToken, Version.VERSION_2_6);
User user = fbClient.fetchObject("me", User.class);
setName("User: "+user.getName());
Statusbar.outputSuccessWithPopup("Welcome! Mr. "+user.getName()).setLeftTopReferenceCentered();
}
}
}catch (Throwable t){
t.printStackTrace();
}
There is no harm in using chrome driver, it will just help you do the job and avoid cluttered code. As you are not able to do same inside c drive put the path to any other drive and put chrome driver exe there.
You should set the chrome driver exe
path like below.
setNewProperty("webdriver.chrome.driver", "D:\some_dir\chromedriver.exe");