python - Testing pages generated via window.showmodaldialog -
i have website generates page via javascript using window.showmodaldialog. when using selenium ide , firefox forced monkeypatch javascript insert new function return value dialog, convert window.showmodaldialog window.open,
driver.execute_script("function setretval(mval) { window.myreturnval = mval; }") driver.execute_script("window.showmodaldialog = function( surl,varguments, sfeatures) { if(window.myreturnval!=null) { var winarg = window.myreturnval; window.myreturnval = null; return winarg; } modalwin = window.open(surl, varguments, sfeatures); return false; }")
and modify onbeforeupload send result back.
driver.execute_script("window.onbeforeunload = function() { window.opener.setretval(window.returnvalue); } ")
i'm trying convert python + selenium webdriver testing purposes. i'd away injecting new javascript during testing. problem
driver.find_element_by_id("maincontent_buttonaccountlookup").click()
triggers code
<a href="#" id="maincontent_buttonaccountlookup" onclick="javascript:calllookup(' account','< %=textboxaccountname.clientid %>','<%=hiddenfieldaccountid.clientid %>') ;return false;"> <img alt="account lookup" src="../images/search.gif" border="0" /> </a>
which doesn't release control python script until window closed.
how initiate click can control of new window, steps , close it?
you can switch new window after opened:
current_window = driver.current_window_handle handle in driver.window_handles: if handle != current_window: driver.switch_to_window(handle) // perform actions // close window driver.switch_to_window(current_window)
Comments
Post a Comment