Reputation: 3
I'm new on protractor, typescript, javascript.. so, I don't know what exactly I'm doing wrong.
The webelement just return a object and I can't perform the action to click on the link. How can I get the linkText? I tryed to use others forms, like id, css, tagname, but for some reason the object gets lost at some point. Someone has this kind of problem?
//html (which is inside 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 gettingMenu(): Promise<void> {
//Mouse over the Main Menu, once this actions is done, a table with submenu appears
await browser.actions().mouseMove(this.mainMenuLink);
//Clicking on the submenu link
await browser.actions().mouseMove(this.subMenuLink);
await browser.actions().click(this.subMenuLink);
}
}
Upvotes: 0
Views: 218
Reputation: 327
You do not need to actually go to the element with the mouse.
You can actually access the element.
Also, you cold get the element, by class(since it has unique class).
element(by.cssContainingText('.secNav', 'Example Main Menu')).click();
or
element(by.css('.secNav')).click();
This should do it, let me know if it works.
Upvotes: 0
Reputation: 392
You're missing .perform() call. From official docs:
Creates a sequence of user actions using this driver. The sequence will not be scheduled for execution until webdriver.ActionSequence#perform is called.
try:
browser.actions().mouseMove(this.subMenuLink).click().perform();
Upvotes: 1