Searching for a troublesome button on my website has become quite the challenge. Everything else seems to be found easily except for this one elusive element that's causing me frustration.
The HTML code is as follows:
<table class="d_FG" role="presentation">
<tbody>
<tr>
<tr id="z_t">
<td class="fct_w" colspan="2">
<div>
<input name="newAttachments_fsid" value="0" type="hidden">
<table id="z_u" class="dcs" role="presentation">
<tbody>
<tr style="border: none;">
<td colspan="3" style="padding-right:0">
<a id="z_v" class="vui-button d2l-button d2l_1_192_930" role="button" tabindex="0" aria-disabled="false">Add a File</a>
<a id="z_w" class="vui-button d2l-button d2l_1_193_372" role="button" tabindex="0" aria-disabled="false">Record Audio</a>
</td>
<td></td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
The specific element I'm struggling to find is:
<a id="z_v" class="vui-button d2l-button d2l_1_192_930" role="button" tabindex="0" aria-disabled="false">Add a File</a>
I've attempted different methods, such as:
public void add_attachment(){
driver.switchTo().defaultContent();
try {
Thread.sleep(2000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
driver.findElement(By.id("z_v"))).click();
}
However, I simply can't seem to get it right. Every time I receive a message saying it's not visible or another element would be clicked instead.
I even tried using a JavaScript function to scroll down to the element, but unfortunately, that didn't work either. Any suggestions would be incredibly helpful at this point.