0

I have used the below code to click on login button but it is not working:

Trial 1:

driver.findElement(By.xpath("//a[text()='https://www.luxproflashlights.com/customer/account/login/referer/aHR0cHM6Ly93d3cubHV4cHJvZmxhc2hsaWdodHMuY29tLw%2C%2C/']")).click(); 

Trial 2:

driver.findElement(By.linkText("Log In")).click();
Corey Goldberg
  • 59,062
  • 28
  • 129
  • 143

1 Answers1

1

If the element contains both the href attribute and the text Log In you can use either of the following Locator Strategies:

  • partialLinkText:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.partialLinkText("Log In"))).click();
    
  • xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//a[contains(@href, 'luxproflashlights') and contains(., 'Log In')]"))).click();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352