Reputation: 11
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();
Upvotes: 0
Views: 35
Reputation: 193088
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();
Upvotes: 1