C#代碼,代碼如下:
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Text.RegularExpressions;
using System.Threading;
using ThoughtWorks.Selenium.UnitTests;
//using NUnit.Framework;
using Selenium;
namespace Selenium_March20
{
[TestClass]
public class UnitTest1
{
private ISelenium selenium;
private StringBuilder verificationErrors;
[TestMethod]
public void TestMethod1()
{
selenium = new DefaultSelenium("127.0.0.1", 4444, "*iexplore", "http://www.baidu.com");
selenium.Start();
selenium.Open("/");
selenium.Type("kw", "hyddd");
selenium.Click("sb");
selenium.WaitForPageToLoad("30000");
Assert.IsTrue(selenium.IsTextPresent("hyddd - 博客園"));
selenium.Click("//table[@id='1']/tbody/tr/td/a/font");
selenium.Close();
selenium.Stop();
}
}
}
運行時出現:
CMD窗口:
IE出現:
VS執行窗口顯示:
由於公司內部上網被限制,所以IE需要設置代理,但是在執行代碼時,代理設置被更改,參加下圖:
這個時候,即使我將代理設置好,在IE中想打開百度,依然打不開網頁,顯示如下:
強力求助!!!感激不盡!!!