B
B
B3L2016-02-15 23:49:24
Java
B3L, 2016-02-15 23:49:24

Selenium webdriver and multiple popup test case complexity. how to modify the test so that you can enter the popup window?

Good day,
I am writing an autotest for a web application and at a certain point there was a difficulty with the localization of an element and clicking on it.
In the Application Menu, autotest should click on a category. a table (dropdown) with subcategories will appear. move the mouse over a subcategory and another table will appear on the right (the difficulty for me begins at this stage of the test) and you need to select and click on a specific place in the table.
The code I wrote allows you to get to the point where the last table appears. but I can't choose anything.

driver.switchTo().frame(driver.findElement(By.id("MainFrame")));
        WebElement MENU = driver.findElement(By.id("Menu"));
        List<WebElement> menuItems = MENU.findElements(By.tagName("td"));
        menuItems.get(4).click();

        Thread.sleep(2000);

        WebElement popupMenu = driver.findElement(By.id("PopupMenu"));
        List<WebElement> popupList = popupMenu.findElements(By.tagName("tr"));
        popupList.get(0).click();

and window code.
<table id="PopupMenu" cellspacing="0" style="padding-left: 0px; padding-right: 0px; top: 38px; left: 358px; visibility: hidden;">
<tbody>
<tr class="TMenuItem" enabled="true" caption="invoice" type="TMenuItem">
<td class="TMenuIcon" width="9px"> </td>
<td class="TMenuItemCaption">invoice</td>
<td class="TMenuArrow"> </td>
</tr>
<tr class="TMenuItem" enabled="true" caption="invoice2" type="TMenuItem">
<td class="TMenuIcon" width="9px"> </td>
<td class="TMenuItemCaption">invoice2</td>
<td class="TMenuArrow"> </td>
</tr>
</tbody>
</table>

Thanks in advance.
UPD:
The solution to the problem was found by manipulating custom xpath locators.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mipan, 2016-02-16
@mipan

Can't why?
Get rid of Thread.sleep(2000) waits altogether and use WebDriverWait.
I will assume that the error is precisely in the lack of waiting for the visibility of the second menu.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question