Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I click on a div button with selenium webdriver?

I have this button:-

 <div class="dsk-col-1-4 card new">
    <div class="div_center_div">
      <span class="icon icon_plus-black-symbol"></span>
      <h2>Create</h2>
    </div>
  </div>

But I tried with find element by classname:-

driver.findElementByClassName("dsk-col-1-4 card new").click();

But it does not work. Any help?

like image 682
Oscar Ubillús Avatar asked Dec 19 '16 20:12

Oscar Ubillús


People also ask

Can we click on Div element in Selenium?

We can select each div separately that have the same class with the help of the Selenium webdriver.

How can I find the XPath of a button inside a div?

From the Elements panel in Chrome's Developer Tools, you can press Ctrl+F and enter an XPath to view the search results for an XPath selector.


1 Answers

Move to your element and click. Example:

new Actions(driver).MoveToElement(yourElement).Click().Perform();
like image 70
Gkumarap Avatar answered Oct 11 '22 18:10

Gkumarap