0

I am trying to automate web application which is AngularJs as frontend ,I am having HTML like below:

<div class="ui-grid-selection-row-header-buttons ui-grid-icon-ok ng-scope" ng-class="{'ui-grid-all-selected': grid.selection.selectAll}" ng-click="headerButtonClick($event)" ng-if="grid.options.enableSelectAll" role="button" tabindex="0"></div>

I want to select an element using ng-class attribute can any one help me out for doing these....

prasanth
  • 75
  • 1
  • 11
  • Any specific requirement to use _ng-class_ leaving aside _class_ ? – undetected Selenium Feb 02 '18 at 05:00
  • No such requirement ,i tried selecting using class but not able to find.And also the selection with ng-click is firing another event not the one desired becoz both are having same ng-click value.So I thought of going with ng-class.If it is possible or if it works with class can u please share thee working code of that... – prasanth Feb 02 '18 at 05:46

1 Answers1

0

As per the HTML you have shared to click on the element you can use the following line of code :

driver.FindElement(By.XPath("//div[@class='ui-grid-selection-row-header-buttons ui-grid-icon-ok ng-scope']")).Click();

As the WebElement is an Angular WebElement you may require to induce WebDriverWait through either of the ways as follows :

  • Using Until :

    WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
    IWebElement myDynamicElement = wait.Until<IWebElement>(d => d.FindElement(By.XPath("//div[@class='ui-grid-selection-row-header-buttons ui-grid-icon-ok ng-scope']")));
    myDynamicElement.Click();
    
  • Using wait.Until(ExpectedConditions.ElementIsClickable(By.by)) :

    WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
    IWebElement myDynamicElement = wait.wait.Until(ExpectedConditions.ElementIsClickable(By.XPath("//div[@class='ui-grid-selection-row-header-buttons ui-grid-icon-ok ng-scope']")));
    myDynamicElement.Click();
    

Update : As per the error you are seeing Element is not clickable at point (245, 310) see this discussion.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • I am getting error as follows:Test Name: Result Message: System.InvalidOperationException : unknown error: Element
    is not clickable at point (245, 310). Other element would receive the click:
    ...
    – prasanth Feb 02 '18 at 06:25
  • Updated my answer with some inputs. – undetected Selenium Feb 02 '18 at 06:37
  • I tried all the ways which you mentioned but I am still getting exception like it is not clickable at (245,310).Can u share the code if it works for you,Any help is highly appreciated.... – prasanth Feb 02 '18 at 07:13
  • Thanks for the post,But it doesn't work for me if you have any other way of doing like with ng-class or with class ,Please do post.. – prasanth Feb 02 '18 at 08:11