Facebook使用Selenium登录C#这是我目前所拥有的(基于这篇文章:TestingFacebookConnectappswithSelenium?)。我无法让它工作。ISeleniumsel=newDefaultSelenium("localhost",4444,"*chrome","http://facebook.com");publicvoidLoginWithEmailAndPassword(stringemail,stringpass){sel.Start();sel.Open("http://www.facebook.com");sel.ClickAt("//img[\@alt='Facebook']","用户点击Facebook登录");sel.WaitForPopUp("","3000");sel.SelectPopUp("");sel.Type("电子邮件",电子邮件);sel.Type("通过",通过);sel.KeyPress("通过","\13");sel.SelectWindow("空");因此,如果有人可以向我提供一些示例代码来说明如何执行此操作,或者为我指明正确的方向,我将不胜感激。已解决通过使用FirefoxSelenium插件的日志记录功能,我获得了id和使其工作所需的功能。登录按钮似乎需要一个XPath定义,我也是从SeleniumIDE获得的。ISeleniumsel=newDefaultSelenium("localhost",4444,"*chrome","http://facebook.com");publicvoidLoginWithEmailAndPassword(stringemail,stringpass){sel.Start();sel.Open("/");sel.Type("id=email",电子邮件);sel.Type("id=pass",通过);sel.Click("//label[@id='loginbutton']/input");尝试使用WebDriver:IWebDriverdriver=newFireFoxDriver();driver.GoToUrl("www.facebook.com");varelement=driver.FindElement(By.Id("email"));element.SendKeys(email);...element=driver.FindElement(By.Id("提交按钮ID"));元素.点击();此链接可以帮助您入门。以上就是C#学习教程:Facebook使用Selenium登录C#分享所有内容。如果对你有用,需要进一步了解C#学习教程,希望大家多多关注。本文收集自网络,不代表立场。如涉及侵权请点击右侧联系管理员删除。如需转载请注明出处: