Beispiel #1
0
        public void isntatWebDrvier()

        {
            this.xmlConfig = Core.GetRMXML("config.xml", true);             //加载xml
            String Browser = xmlConfig.gNode("Platform/Browser").InnerText;

            Console.WriteLine("浏览器:" + Browser);

            if ("google".Equals(Browser))
            {
                drvier = new ChromeDriver();
                Console.WriteLine("goole浏览器:" + Browser);
            }
            else if ("ie".Equals(Browser))
            {
                InternetExplorerOptions options = new InternetExplorerOptions();
                options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
                drvier = new InternetExplorerDriver(options);
                Console.WriteLine("ie浏览器:" + Browser);
            }
            else if ("fox".Equals(Browser))
            {
                // drvier = new FirefoxDriver();
            }
            else
            {
                Console.WriteLine("浏览器配置错误:" + Browser);
            }
        }
Beispiel #2
0
        public void init()
        {
            //启动浏览器
            WebDriver seleiun = new WebDriver();

            drive = seleiun.getDriver();
            //读取config参数,读取ip
            this.xmlConfig = Core.GetRMXML("config.xml", true);       //加载xml
            string weburl = xmlConfig.gNode("Platform/IP").InnerText; //读取xml参数

            drive.Navigate().GoToUrl(weburl);                         //s输入网址
            ple = new LocatYyaml(drive, "Xpath.txt");                 //传递webdr对象,读取文件参数
            Console.WriteLine("初始化:访问地址URL:{0}", weburl);
            // drive.Manage().Window.Maximize();   //窗口最大化
        }
Beispiel #3
0
        public void init()
        {
            //启动浏览器
            WebDriver seleiun = new WebDriver();

            drive = seleiun.getDriver();
            //读取config参数,读取ip
            this.xmlConfig = Core.GetRMXML("config.xml", true);       //加载xml
            string weburl = xmlConfig.gNode("Platform/IP").InnerText; //读取xml参数

            drive.Navigate().GoToUrl(weburl);                         //s输入网址
            ple = new LocatYyaml(drive, "Xpath.txt");                 //传递webdr对象,读取文件参数
            Console.WriteLine("初始化:访问地址URL:{0}", weburl);
            // drive.Manage().Window.Maximize();   //窗口最大化
            Selp.sl(5);
            ple.getElement("user").Clear(); ple.getElement("pwd").Clear(); //清楚用户密码
            ple.getElement("pwd").SendKeys(pwd);                           //管理员密码amdin
            ple.getElement("login").Click();
            Selp.sl(3);
        }
Beispiel #4
0
        //等待元素时间
        private IWebElement waitForElement(By by)
        {
            IWebElement myDynamicElement = null;

            xmlConfig = Core.GetRMXML("config.xml", true);                             //加载xml
            Double Time = Convert.ToInt32(xmlConfig.gNode("Platform/Time").InnerText); //获取等待时间,强转

            try
            {
                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(Time));
                myDynamicElement = wait.Until <IWebElement>((d) =>
                {
                    return(d.FindElement(by));  //定位到,并返回
                });
            }
            catch (Exception)
            {
                Console.WriteLine("超时{1} ,不存在:{0}", by.ToString(), Time);
            }
            return(myDynamicElement);
        }