Пример #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);
            }
        }
Пример #2
0
        public void UserSet()
        {
            string    factory, devid, bn, bid, ln, did, dname; //预期序列号、自编号、车牌号、自编号、线路号、司机工号、司机姓名
            ArrayList Fanem = new ArrayList();                 //实际获取的值

            factory = xmlConfig.gNode("Assertion/factory").InnerText;
            Console.WriteLine("获取的序列号:{0}", factory);
            ple.getElement("config_font_size").Click();
            Selp.sl(5);
            string Fact = ple.getElement("序列号").Text;

            Fanem.Add(Fact);
            Console.WriteLine("实际序列号:{0}", Fact);
            Assert.AreEqual(factory, Fact);
            string fa4 = Fact.Substring(0, 4);                //截取边序列


            ple.getElement("车牌号").Clear();            //清空内容
            ple.getElement("车辆自编号").Clear();
            ple.getElement("线路号").Clear();
            ple.getElement("工号").Clear();
            ple.getElement("dname").Clear();

            Console.WriteLine("输入自编号/车牌号:{0}", fa4);
            ple.getElement("序列号").SendKeys(fa4);
            ple.getElement("车牌号").SendKeys(fa4);
            ple.getElement("车辆自编号").SendKeys("fa4");
            ple.getElement("线路号").SendKeys("fa4");
            ple.getElement("工号").SendKeys("fa4");
            ple.getElement("dname").SendKeys("fa4");
            Selp.sl(10);
        }
Пример #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);                         //输入网址
            ple = new LocatYyaml(drive, "Xpath.txt");                 //传递webdr对象,读取文件参数
            Console.WriteLine("初始化:访问地址URL:{0}", weburl);
            // drive.Manage().Window.Maximize();   //窗口最大化
            Selp.sl(3);
            Console.WriteLine("user password");
            ple.getElement("user").Clear(); ple.getElement("pwd").Clear(); //清楚用户密码
            pwd = xmlConfig.gNode("Platform/pwd").InnerText;               //获取密码
            ple.getElement("pwd").SendKeys(pwd);                           //管理员密码amdin
            ple.getElement("login").Click();
            Selp.sl(3);
        }
Пример #4
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();   //窗口最大化
        }
Пример #5
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);
        }
Пример #6
0
 public void TestSetUp()
 {
     pwd = xmlConfig.gNode("Platform/pwd").InnerText;
     Console.WriteLine("TestSetUp");
 }