0

我正在使用 selenium 和 c# .NET4.0 在 Firefox 上自动执行一个过程:

    static void Main(string[] args)
    {
        selenium = new DefaultSelenium("localhost", 4444, "*firefox", "https://www.microsoft.com/");

        selenium.Start();
        selenium.SetSpeed("900");

        selenium.WindowMaximize();
        selenium.WindowFocus();

        Login();
     }

public static void LogIn()
        {
            verificationErrors = new StringBuilder();

        selenium.SetSpeed("900");
        selenium.Open("/Login.aspx");

        selenium.Type("id=ctl00_cphBody_objLogin_UserName", "user");

        selenium.Type("id=ctl00_cphBody_objLogin_Password", "P@assword");

        selenium.Click("id=ctl00_cphBody_objLogin_LoginImageButton");

        selenium.WaitForPageToLoad("30000");    

            try
            {
                selenium.IsTextPresent("Orders - Drug Testing");

            }
            catch (Exception)
            {
                Console.WriteLine("Could't find text: Orders - Drug Testing.");

            }


    }

Firefox 打开,然后什么也没有发生。它不会导航到请求的页面。

这就是它的样子。我究竟做错了什么?一切正常IE

在此处输入图像描述

4

1 回答 1

2

要导航到请求的页面,需要使用以下代码。

Selenium 不会自动导航到页面或基本 url 直到 & 除非你打电话

selenium.open(" < your url goes here > ");

前任 :selenium.open("https://mail.google.com");

于 2012-07-27T05:01:52.910 回答