I'm trying to open a menu in a list of menus' and then click on a link in the menu. the menu list structure is like there are two links side by side. one link goes to the main section that gives the summary and the other one opens the menu. I can click on the link that goes to the main section but couldn't click on the link that opens the menu though the XPath I've used can uniquely identify the menu link. The HTML is :
<li _ngcontent-c9="" class="list-group-item d-flex justify-content-between align-items-center">
<i _ngcontent-c9="">...</i>
<div _ngcontent-c9="" class="center" style="font-family: ITC Avant Garde Gothic Std Book;font-size: 20px;">
<a _ngcontent-c9="" routerlink="../someText/mainlink" href="#/someText/mainlink">Main Link</a>
<span _ngcontent-c9="" style="padding-left:40%">
<a _ngcontent-c9="" class="fa fa-bars" data-target="#basicExample" data-toggle="modal" placement="left">
</a>
</span>
</div>
</li>
I need to get to the link under the span
.
There is no text Menu Link
. I've added that text so that the structure can be understood. The XPath I've used for the menu link:
.//a[./text()='Main Link']/../span/a
The XPath I've used for the main link is:
.//a[./text()='Main Link']
Also, I've defined that element using the page factory as:
@FindBy(linkText='Main Link')
WebElement mainLink;
Both are working when I try to click on the main link. but I couldn't click on the menu link beside it. I've implemented an explicit wait for 20 seconds. I'm getting TimeOutException
.