Can anyone help how to click the below link using selenium
<a class=”btn btn-primary btn-large” href="target-URL">Submit</a>
I tried using below options
- linkText
- partialLinkText
- CssSelector
- contains - logic which checks the URL text
Can anyone help how to click the below link using selenium
<a class=”btn btn-primary btn-large” href="target-URL">Submit</a>
I tried using below options
You can try:
driver.findElement(By.xpath("//a[contains@class,'btn '] and contains(@class, 'btn-large') and contains(text(), 'Submit')")).click()
In theory, this is just:
driver.findElment(By.linkText("Submit")).click();
But, I'm pretty sure you've already tried that. Check if the element is in iframe/frame. If yes, you need to switch to it and only then find the link element:
driver.switchTo().frame("frame_name_or_id");
To switch back in the main context, use defaultContent():
driver.switchTo().defaultContent();