How to click Onclick Javascript form using Selenium?

后端 未结 3 1629
悲&欢浪女
悲&欢浪女 2021-02-15 10:31

This is my source code :

Add a
相关标签:
3条回答
  • 2021-02-15 10:58

    CSS selector is faster than XPATH so you can try

    driver.findElement(By.cssSelector("a.add-link")).click();
    
    0 讨论(0)
  • 2021-02-15 11:01

    You can also use following xpath codes:

    driver.findElement(By.xpath("//a[@onclick='gotoPaymentAddressForm()']")).click();
    

    or

    driver.findElement(By.xpath("//a[contains(text(),'Add a New Credit Card')]")).click();
    
    0 讨论(0)
  • 2021-02-15 11:15

    Try with following:

    driver.findElement(By.linkText("Add a New Credit Card")).click();
    
    0 讨论(0)
提交回复
热议问题