1

I have below page and I need to click on User Login.

I am unable to locate an element to proceed with.

<a class="nav-link page-scroll login-a ng-binding" data-toggle="modal" data-target="#loginToast" href="javascript:void(0);" ng-click="vm.showLoginToast({},'login');" ng-class="{'urdu-login-mobile':language==='UR' || language==='ur'}">User Login</a>
6
  • Kindly donot post images of your code instead copy paste them so that we can debug it easily. Commented Dec 13, 2019 at 7:07
  • <a class="nav-link page-scroll login-a ng-binding" data-toggle="modal" data-target="#loginToast" href="javascript:void(0);" ng-click="vm.showLoginToast({},'login');" ng-class="{'urdu-login-mobile':language==='UR' || language==='ur'}">User Login</a> Commented Dec 13, 2019 at 7:12
  • Can you explain your question a bit more it is not clear what is the error , what is the expected output. Commented Dec 13, 2019 at 7:15
  • unique identifier as in id attribute? Commented Dec 13, 2019 at 7:23
  • yes, as in id attribute Commented Dec 13, 2019 at 9:21

1 Answer 1

1

The element is Angular element so to click() on the element you have to induce WebDriverWait for the element to be clickable and you can use either of the following Locator Strategies:

  • Using Java and cssSelector:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("a.nav-link.page-scroll.login-a.ng-binding[data-toggle='modal'][data-target$='loginToast']"))).click();
    
  • Using Python and XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[@class='nav-link page-scroll login-a ng-binding' and @data-toggle='modal'][text()='User Login']"))).click()
    
Sign up to request clarification or add additional context in comments.

1 Comment

@ShipraSaxena As per StackOverflow best practices you need to raise a new question with your new requirement, Stackoverflow contributors will be happy to help you out and you can choose the best answer among several which caters to your need.

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.