Beispiel #1
0
        public void Login(string Url, string driverPath, string userName, string Password)
        {
            //If password is null replace empty value
            Password = Password != null ? Password : "";
            //预上线环境账号
            ChromeOptions CROptions = new ChromeOptions();

            CROptions.AddArgument("-start-maximized");
            CROptions.AddArgument("--disable-gpu");
            if (!DataStatus.ProcessModel)
            {
                string ChromeXpathpath = Directory.GetCurrentDirectory().ToString() + "\\tools\\ChromeXpath.crx";
                CROptions.AddExtension(ChromeXpathpath);
            }
            driver = new ChromeDriver(driverPath, CROptions);
            DataStatus.SetWebDriver(driver);
            driver.Url = Url;
            JWait.WaitForAjaxComplete(driver, 30);
            if (!JWait.WaitUntil(() =>
            {
                element = driver.FindElement(By.XPath("//input[@placeholder='用户名']"));
                element.Clear();
                element.SendKeys(userName);
                element = driver.FindElement(By.XPath("//input[@placeholder='密码']"));
                element.Clear();
                element.SendKeys(Password);
                element = driver.FindElement(By.XPath("//button[contains(text(),'登录')]"));
                element.Click();
                SwitchWebpage(driver.WindowHandles.Count);
            }, 30))
            {
                throw new Exception("✘:【登录失败】");
            }
        }
Beispiel #2
0
 public void ScrollTo(string Tvalue)
 {
     JWait.WaitForAjaxComplete(driver, 10);
     JS.scrollJS(driver, Tvalue);
 }