D.Shah D.Shah - 1 month ago 7
HTML Question

Selenium: clicking - div within a div

I have this:

<div class="dhx_toolbar_btn def" title="">
<div>Interface</div>
</div>


and was wondering how I would get Selenium to click on it, as I tried this:

//div[@class='dhx_toolbar_btn def' and contains(., 'Interface')]


and this:

css=.dhx_toolbar_btn def:contains('Interface')


but neither seems to work at all, however it appears to work with other divs that are like this:

<td class="td_btn_txt">
<div class="btn_sel_text">Billing Interface</div>
</td>


Any help is appreciated.
Thanks

**EDIT**

I have also tried these but all don't work, and also don't return any errors:

//div[5]/div/div[5]/div[9]
//*[text()='Interface']
//*[normalize-space(text())='Interface']
//*[contains(text(), 'Interface')]


**EDIT**

I also just noticed, when I try these last 4 but with a mouseDown instead of a click it does exactly what it is supposed to, (make it look like the mouse is on the item, but not click it), so I am wondering why it would do what it is meant to with mouseDown, but with click it does nothing, not even return an error.

Answer

Okay, so not exactly the way I wanted it to go, or to make it work but it kinda does:

<tr>
<td>waitForElementPresent</td>
<td>//div[@class='dhx_toolbar_btn def' and contains(., 'Interface')]</td>
<td></td>
</tr>
<tr>
<td>mouseDown</td>
<td>//*[text()='Interface']</td>
<td></td>
</tr>
<tr>
<td>mouseOver</td>
<td>//*[normalize-space(text())='Interface']</td>
<td></td>
</tr>
<tr>
<td>mouseDown</td>
<td>//*[text()='Interface']</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[5]/div/div[5]/div[9]</td>
<td></td>
</tr>
<tr>
<td>mouseOut</td>
<td>//div[5]/div/div[5]/div[9]</td>
<td></td>
</tr>

Although I would prefer an easier & simpler method.