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
  • 56,214
  • 26
  • 121
  • 139

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
  • 151,581
  • 34
  • 225
  • 281