2
    driver.FindElement(By.XPath("//textarea[@ng-model='vm.system.systemdescription']")).SendKeys("abc"); //is able to find element. 
Whereas if do same thing using ngDriver i'm getting 

> async timeout exception or javascript Invalid operation exception 

    ngDriver.FindElement(NgBy.Model("vm.system.systemdescription")).SendKeys("jkgf"); 


Also tried the following but doesn't help
ngDriver.FindElement(NgByModel.Name("vm.system.systemdescription")).SendKeys("jkgf"); also does not work.                                            

Here is d code snippet                                                                              private IWebDriver driver = new InternetExplorerDriver();
        private NgWebDriver ngDriver;
        private WebDriverWait wait;
        private Actions actions;
        private int wait_seconds = 30;

        [SetUp]
        public void InitializeBrowserToSearchEngine()
        {                   ngDriver = new NgWebDriver(driver);
            driver.Navigate().GoToUrl("req_url");
             driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(60));
            ngDriver = new NgWebDriver(driver);
wait = new WebDriverWait(driver, TimeSpan.FromSeconds(wait_seconds));
            actions = new Actions(driver);
            Console.WriteLine("Opened Browser with the given URL");
        }
[Test]
        [Order(6)]
        public void OpenNewSystemConfig()
        {
            string url = "req_url";
            ngDriver.Url = url;
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            WebDriverWait w1 = new WebDriverWait(ngDriver, TimeSpan.FromSeconds(10));
            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("Administration_1")));
            driver.FindElement(By.Id("Administration_1")).Click();
            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("System_Configuration_0")));
            driver.FindElement(By.Id("System_Configuration_0")).Click();

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath("//textarea[@ng-model='vm.system.systemdescription']")));
            Thread.Sleep(5000);
            driver.FindElement(By.XPath("//textarea[@ng-model='vm.system.systemdescription']")).SendKeys("ijfk");
            //w1.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(NgBy.Model("vm.system.systemdescription")));
            //ngDriver.FindElement(NgBy.Model("vm.system.systemdescription")).SendKeys("jkgf"); ;

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath("//select[@data-ng-model='vm.system.SystemTypeId']")));
            driver.FindElement(By.XPath("//select[@data-ng-model='vm.system.SystemTypeId']"));
            //wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(NgBy.Model("vm.system.systemdescription")));
            //ngDriver.FindElement(NgByModel.Name("vm.system.SystemTypeId"));
            // ngDriver.FindElement(NgByModel.ClassName("form-control ng-pristine ng-untouched ng-valid ng-not-empty ng-valid-required"));
               }

注释代码不起作用。我需要使用量角器通过 ng-model 和 ng-binding 查找元素。由于没有使用 Xpath,我需要一种方法来找到没有 id 和角度组件的元素,可以通过定位器(例如 ng-model 和 ng-binding)找到。我还使用 nuget 包管理器在参考中添加了量角器,请帮助解决

4

1 回答 1

-2

试试看嘛element(by.model("vm.system.systemdescription")).sendKeys('jkgf);

您的命令中有错字 sendKeys 应该以小写字母 's' 而不是 'S' 开头

希望这可以帮助..

于 2016-11-21T11:48:52.277 回答