Skip to content Skip to sidebar Skip to footer

Selenium: Click On A "
" Button

I tried to click on a button. It has this structure:
Copy
  • using By.linkText() :-

    driver.findElement(By.linkText("Verify Connection")).click();
    
  • using By.xpath() :-

    driver.findElement(By.xpath(".//a[normalize-space(.) = 'Verify Connection']")).click();
    
  • If you're still unable to perform click, try as an alternate solution using JavascriptExecutor as below :-

    ((JavascriptExecutor)driver).executeScript("arguments[0].cli‌​ck()", driver.findElement(By.cssSelector("div#button-verify-wrapper > a")));
    

    Solution 2:

    You should click on the link using a css selector like: a[x-ng-click*='verifySfdcConnection']

    Solution 3:

    driver.findElement(By.id("button-verify-wrapper")).click();

    Note: 1. if ID or class name is directly given no need to use xpath, can directly use By.id and By.class 2. To perform an action on web element we should know the properties of that element ex. if it is not a button you can not perform click on it

    Solution 4:

    try this: $("#button-verify-wrapper > a").click()

    Post a Comment for "Selenium: Click On A "
    " Button"