1

I have been writing some selenium scripts whereby I am selecting some options from a drop down list. When I hover over the parent list, it displays a list of children from where I can select an option. This functionality has been working fine for numerous elements, but I have one which is resulting in a 'ElementNotVisibleException'.

I've attached 2 examples of the code I have been using. The top method is working, but the 2nd one I am experiencing issues with. If anyone can help as to why I might be getting this error I would appreciate it.

WORKS

    public static void creditNoteReportFocus(InternetExplorerDriver driver)
{
    driver.findElement(By.xpath("//a[contains(@href, 'CreditNoteReport')]")).sendKeys(Keys.ENTER);
}

DOESN'T WORK

public static void earlySettlementWorkflowFocus(InternetExplorerDriver driver) throws InterruptedException
{
    driver.findElement(By.xpath("//a[contains(@href, 'EarlySettlementMatch?StartUpView=0')]")).sendKeys(Keys.ENTER);
}

SCREENSHOT enter image description here

CODE SNIPPET OF HTML

<div class="inner">
    <img alt="barney" runat="server" src="/DibsAndrew/images/chinook/gfx-topnav-left.gif"/>
    <ul class="drop-down-menu sub-nav">
        <li>
        <li>
        <li>
        <li>
            <a class="highlighted" href="/DibsAndrew/CCLReports/Overall">Reports</a>
            <ul id="ddm-86476" style="display: block;">
                <li>
                <li>
                    <a class="highlighted" href="#">Collections</a>
                    <span>»</span>
                    <ul style="display: block;">
                        <li>
                        <li>
                        <li>
                        <li>
                        <li>
                        <li>
                        <li>
                            <a class="highlighted"  href="/DibsAndrew/ETCalculator/EarlySettlementMatch?StartUpView=0">Early Settlement Workflow</a>
                        </li>
9
  • Please provide a HTML snippet that shows the element(s) in question so we can help you out, thanks. Commented Dec 3, 2014 at 16:35
  • Hi Mark, details are now attached. Thanks Commented Dec 3, 2014 at 16:44
  • Screenshots are useless for showing code! In your second XPath, what are the asterisks outside of the single-quotations suppose to be?
    – SiKing
    Commented Dec 3, 2014 at 16:45
  • Simon, please no longer comment on my questions as I am fed up of your sarcastic and condescending responses. many thanks Commented Dec 3, 2014 at 16:47
  • 1
    Oh the exception stems from the element not being visible. For some reason I thought it was element not found exception. It is possible that the code executes before the element becomes visible in case of dynamic nature of the menu. Try adding a wait for visibility as mentioned in this post.
    – shri046
    Commented Dec 3, 2014 at 18:14

1 Answer 1

1

I have had to use absolute xpath in order to resolve this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.