首页 > 代码库 > WebDriverTest

WebDriverTest

using OpenQA.Selenium.Firefox;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using OpenQA.Selenium;

namespace WebDriverTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var driver = new FirefoxDriver();
            driver.Url = "http://192.168.0.252/";
            driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(3);
            driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(2);

            driver.FindElementById("_easyui_textbox_input1").SendKeys("ERIC");
            driver.FindElementById("_easyui_textbox_input3").SendKeys("ERIC");

            Thread.Sleep(TimeSpan.FromSeconds(3));

            driver.ExecuteScript("f_Login();");

            Thread.Sleep(TimeSpan.FromSeconds(3));

            driver.FindElementByCssSelector("[data_funid=‘1A101‘]").Click();

            IWebElement frameEl = driver.FindElementByTagName("iframe");

            driver.SwitchTo().Frame(frameEl);

            driver.FindElementById("aAdd").Click();
            driver.FindElementById("_easyui_textbox_input2").SendKeys("Test");


            //var driver = new FirefoxDriver();
            //driver.Url = "https://www.baidu.com/";
            //driver.FindElementById("kw").SendKeys("WebDriver");
            //driver.FindElementById("su").Click();

        }
    }
}

 

WebDriverTest