I made a login automation application with C# + .NET - MVC.
My application works perfectly on my local computer and saves everything on the database.
Once I deployed my application on our local machine, the Index View receives the email and password, sends them to the database and saves them. The next step firing up a WebDriver (Firefox or Chrome worked on laptop) with Selenium. Here, nothing happens. It keeps waiting on the localhost forever and both Chrome and FF timeout after a certain period of time.
[HttpGet]
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult getInformation()
{
email = Request["getEmail"].ToString();
password = Request["getPassword"].ToString();
saveLogin();
return RedirectToAction("gatherer");
}
public ActionResult gatherer()
{
facebookLogin();
return null;
}
private static void facebookLogin()
{
chrome = new FirefoxDriver();
chrome.Navigate().GoToUrl("http://facebook.com");
chrome.FindElement(By.Id("email")).SendKeys(email);
chrome.FindElement(By.Id("pass")).SendKeys(password);
chrome.FindElement(By.Id("loginbutton")).Click();
}
This is very simple and it worked on my local computer again. But deployed on IIS on the server, it doesn't. In other words : the webdriver never opens.
First you need to change from
chrome = new FirefoxDriver();
To
DesiredCapabilities capability = DesiredCapabilities.Firefox();
Uri url = new Uri("http://REMOTE_IP:5050/wd/hub");
IWebDriver chrome = new RemoteWebDriver(url, capability);
Then Download Selenium Standalone server and use command prompt to initiate it using
java -jar C:\selenium-server-standalone-2.24.1.jar -interactive -port 5050
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.