【发布时间】:2015-05-08 05:47:57
【问题描述】:
我是编程新手。我在 VisualStudio C# 中使用窗口窗体。 我的问题是单击窗口窗体中的第一个按钮后,它会打开浏览器并转到我要登录的 URL,然后当我单击窗口窗体上的第二个按钮时,它不会运行第二个代码块.我没有收到任何错误消息。 任何人都可以帮助我,因为我完全是一个初学者。提前非常感谢您!
public partial class Form1 : Form
{
IWebDriver driver = null;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
driver = new FirefoxDriver();
driver.Url = "https://accounts.google.com/ServiceLogin";
driver.Manage().Window.Maximize();
}
private void button2_Click(object sender, EventArgs e)
{
driver.Url = "https://accounts.google.com/ServiceLogin";
var email = driver.FindElement(By.Id("Email"));
email.SendKeys("-------------");
var password = driver.FindElement(By.Id("Passwd"));
password.SendKeys("---------");
password.FindElement(By.Id("signIn"));
【问题讨论】:
-
请根据您的具体问题更改标题。 meta.stackexchange.com/questions/10647/…
-
**private void button2_Click上的两个星号 (*) 是您的代码还是您在此问题中添加了它们? -
我在这里暗示,代码编译得很好,因为作者测试了他的应用程序,所以**是为了说明热点。
-
作为旁注,您应该在您的网址前加上
@。如果您想了解更多信息,请搜索verbatim string literal。 -
感谢您的帮助。为大家点赞!