1

I have the code which I am trying to run in Selenium webdriver. It is a button but I can't select it with java code. Can you please help me which is true ?

<mat-list-item _ngcontent-c7="" class="menu-item mat-list-item ng-star-inserted" id="kisiler"><div class="mat-list-item-content"><div class="mat-list-item-ripple mat-ripple" mat-ripple=""></div><div class="mat-list-text"></div>
          <!----><mat-icon _ngcontent-c7="" class="mat-icon material-icons ng-star-inserted" role="img" aria-hidden="true">group</mat-icon>
          <!---->
          <!----><mat-label _ngcontent-c7="" class="ng-star-inserted">Kişiler</mat-label>
        </div></mat-list-item>

My code is:

driver.findElement(By.id("[@id='kisiler']")).click();
2
  • correct your code driver.findElement(By.id("kisiler")).click(); Commented Oct 4, 2018 at 8:15
  • it doesnt work @NarendraR , and the exception is Exception in thread "main" org.openqa.selenium.ElementClickInterceptedException: Element <mat-list-item id="kisiler" class="menu-item mat-list-item ng-star-inserted"> is not clickable at point (94.5,144) because another element <div class="apsi-container"> obscures it Commented Oct 4, 2018 at 8:20

1 Answer 1

2

To click on the element with text as Kisiler you need to induce WebDriverWait for the element to be clickable and you can use the following solution:

  • xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//mat-list-item[@class='menu-item mat-list-item ng-star-inserted' and @id='kisiler']//mat-label[@class='ng-star-inserted']"))).click();
    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.