Selenium, cannot find button to click



  • I got stuck to write the code in WebDriver. I have the code below :

    <button class="btn" onclick="javascript:return PopulateInvestor('hdnInvestorId', 'txtInvestorName', 'txtInvestorEmail', '', '', '', '', '',false,'hdnInvestorName','hdnInvestorEmail');">Select</button>
    

    For this I wrote the following:

    JavascriptExecutor jse = (JavascriptExecutor)driver;        
    jse.executeScript("document.getElement(By.xpath(\"//div[@class='modal-footer']/button[@onclick'return javascript:return PopulateInvestor('hdnInvestorId', 'txtInvestorName', 'txtInvestorEmail', '', '', '', '', '',false,'hdnInvestorName','hdnInvestorEmail');']\").click()");

    But still it could not identify element and could not click the button. I can see there is select button present at the end of the code but don't know how to use it. Please advise for this.



  • Try this line of code:

    Driver.findElement(By.xpath("enter your xpath")).click();

    Hope it works out!



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2