量角器网,无角登录页面(Protractor-net, non angular login page

2019-10-22 06:59发布

用量角器网,登录页面是non-angular ,其中作为主页的角度。 因此不能用启动浏览器url使用NgWebDriver ,可能因为其找角度。 试图angular.ignoreSynchronization="false" 。 但同样的问题。 如果我使用angDriver.WrappedDriver.FindElement穿越登录,在主页的角度对象不recognized- Asynchronous脚本错误超时。

driver = new ChromeDriver("C:\\FTWork\\DriverFiles\\chromedriver_win32\\");
driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(20));
angDriver = new NgWebDriver(driver,"[ng-app='Phoenix']");
string root=angDriver.RootElement;
angDriver.WrappedDriver.Navigate().GoToUrl(url);
angDriver.WrappedDriver.Manage().Window.Maximize();
driver = angDriver.WrappedDriver;
driver.FindElement(By.Id("UserID")).Clear();
driver.FindElement(By.Id("UserID")).SendKeys("");
driver.FindElement(By.Id("Password")).SendKeys("");
driver.FindElement(By.Id("searchsubmit")).Click();
System.Threading.Thread.Sleep(10000);
string dolAmt = angDriver.FindElement(NgBy.Binding("activeValue")).Text;

Answer 1:

我希望这会做到这一点。

_driver = new ChromeDriver("C:\\FTWork\\DriverFiles\\chromedriver_win32\\");
_driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(10));;
//Do whatever for log in with chrome driver

string url = "url for angular page";
_ngWebDriver = new NgWebDriver(_driver, "[ng-app='Phoenix']");
//You have to naviagate to url in order the _ngWebDriver to know the angular page NOT click and go to angular page
_ngWebDriver.Navigate().GoToUrl(url);
_ngWebDriver.Manage().Window.Maximize();
//The script timeout is almost essential since most of protractor mechanism are dependent of client side script.    

//start finding elements with NgBy class
NgWebElement ngElement = _ngWebDriver.FindElement(NgBy.Model("model"));
ngElement.Clear();

编辑

driver = new ChromeDriver("C:\\FTWork\\DriverFiles\\chromedriver_win32\\");
driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(20));
driver.FindElement(By.Id("UserID")).Clear();
driver.FindElement(By.Id("UserID")).SendKeys("");
driver.FindElement(By.Id("Password")).SendKeys("");
driver.FindElement(By.Id("searchsubmit")).Click();


// Phoenix is the ng-app of the coming angular page
string url = "url for angular page containing [ng-app='Phoenix']"
NgWebDriver angDriver = new NgWebDriver(driver,"[ng-app='Phoenix']");

// don't switch to wrapper driver
angDriver.Navigate().GoToUrl(url);
angDriver.Manage().Window.Maximize();
driver = angDriver.WrappedDriver;
string dolAmt = angDriver.FindElement(NgBy.Binding("activeValue")).Text;


文章来源: Protractor-net, non angular login page