java - selenium firefox modal displays as a pop-up window, not a modal -
i'm trying use selenium test out form on website consists of multiple pages. there modals suppose appear on of pages based on options selected. i'm having trouble getting selenium work fireforx , modals. chrome acts expected, , haven't bothered i.e. yet.
- when work through pages manually firefox, works expected.
- when run selenium script modal displays windows pop-up window, not modal.
i'm using driver.switchto().alert().accept(); handle modals, , first modal encounter close, once next page selenium code unable find of elements on page.
here code use click button:
public void pushbutton(string[] values) { system.out.println("\t click (" + values[1] + ")"); setlocator(values[0], values[1]); try { clickwhenready(locator).click(); } catch (exception e) { system.out.println("could not find id or xpath value: " + values[1]); e.printstacktrace(); } } private void setlocator(string bytype, string value) { if(bytype.touppercase().equals("id")) { locator= by.id(value); } else if(bytype.touppercase().equals("xpath")){ locator= by.xpath(value); } } private webelement whenready(by locator){ webelement element = (new webdriverwait(driver, 30)) .until(expectedconditions.presenceofelementlocated(locator)); return element; } private webelement clickwhenready(by locator){ webelement element = (new webdriverwait(driver, 30)) .until(expectedconditions.elementtobeclickable(locator)); return element; }
first of all, modals not alerts so, driver.switchto().alert().accept(); not going buy anything.
the real issue modals take longer fade out , blocking selenium interact page. best bet try waiting modal disappear dom , try interacting elements. can use invisibilityofelementlocated of expectedconditions or similar mechanism. see this
Comments
Post a Comment