2016-11-21 5 views
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パッケージマネージャ を使用して参照して分度器を追加したNgModelを見つけることができません

+0

'Install-Package Protractor'を使用して.netパッケージの分度器をインストールしましたか? –

+0

可能であれば、要素のhtmlスニペットを貼り付けてください。 – lauda

+0

答えて

-2

を解決するために助けてくださいちょうどあなたのコマンドのSendKeysにタイプミスがありelement(by.model("vm.system.systemdescription")).sendKeys('jkgf);

を試してみてください小さなケース「S」ではない「Sで始まる必要があります'

これは役に立ちます..

+0

注:これはC# - ' SendKeys() 'が正しいです。 – alecxe

+0

ありがとう@ダニー。しかし、タイプミスはありません。 C#では、その大文字のみ - パスカル・ケーシング符号化標準に従って。 –

+0

ngDriver.FindElement(NgByModel.Name( "vm.system.systemdescription"))。SendKeys( "jkgf");また動作しません。 –

関連する問題