I have the following code:

<span class="login-link control" ng-switch="loggedIn()">        
        <!-- ngSwitchWhen: true -->
        <a class="site-control ng-binding ng-scope" ng-switch-when="true" ng-click="logout()" href="javascript:void(0)">Logout</a>
        <!-- end ngSwitchWhen: -->

and used the following xPath's and Css selectors that I've tried out in the Developer console and each time it highlights the code but when I run the code it just sits there but doesn't click on the link


    //*[contains(@class, 'site-control ng-binding ng-scope') and contains(text(),'Logout')]

    //a[@class='site-control ng-binding ng-scope']




    //a[contains(@href, 'javascript:void(0)')]

    css - [ng-click='logout()']

My current code that does get me to the correct page is:

WebDriverWait wait = new WebDriverWait(driver, 20);
        WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[contains(@class, 'site-control ng-binding ng-scope') 

IntelliJ current error:

   [![org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to be clickable: By.xpath: //*\[contains(@class, 'site-control ng-binding ng-scope') and contains(text(),'Logout')\] (tried for 20 second(s) with 500 MILLISECONDS interval)][1]][1]
  • 1
    Hi could you change the expected condition from clickable to element present instead and see of you are actually getting the element or not ? – PDHide Jan 11 at 7:16
  • If that works fine., could you try getting the value of isdisplayed and isenabled , see if both are returning true or not . For isclicable to work both should return true . – PDHide Jan 11 at 8:04
  • Try clicking span instead of a – PDHide Jan 11 at 8:43
  • Thank you! I will try that right now. I haven't had a chance to work on it yet. – ameuzela Jan 14 at 4:48
  • I ran this: if(driver.findElements(By.xpath("//span[@class='site-control ng-binding ng-scope']")).size() != 0){ System.out.print("Element is Present") }else{ System.out.print("Element is Absent") } and it said that the "Element is Absent" – ameuzela Jan 14 at 5:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.