I'm new to using Protractor, TypeScript, and JavaScript, so I'm unsure of what exactly I might be doing wrong.
The web element simply returns an object and I am unable to perform the action of clicking on the link. How can I retrieve the linkText? I've tried using other methods like id, css, tagname, but for some reason, the object seems to get lost at some point. Has anyone else experienced this issue?
//html (within a frame)
<div class="menuLabel" id="menuLabel1"> </div>
<div class="submenubox" id="submenu1"> </div>
<div class="menuLabel" id="menuLabel2">
<table>
<tbody>
<tr>
<td></td>
<td class="menuText">
<nobr>
<a onmouseover="menuShow(event,'2')" href="javascript:void(null)" class="ml">Example Main Menu</a>
</nobr>
</td>
</tr>
</tbody>
</table>
</div>
<div class="submenubox" id="submenu2">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="anything">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr> </tr>
<tr>
<td class="secNav">
<a onmouseover="subMenuShow(event, '2', '1')" ; hoverText='Example Sub Menu' target href="trade/new.action">...</a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
//Page Object file
export class PageObject {
public mainMenuLink: WebElement = element(By.linkText('Example Main Menu'));
public subMenuLink: WebElement = element(By.linkText('Example Sub Menu'));
async getMenuAction(): Promise<void> {
//Hover over the Main Menu, causing a table with submenu to appear
await browser.actions().mouseMove(this.mainMenuLink);
//Click on the submenu link
await browser.actions().mouseMove(this.subMenuLink);
await browser.actions().click(this.subMenuLink);
}
}