我正在使用Selenium-2
和Python
。在点击图像时,我应该得到一个新的模态窗口替换当前的窗口。新窗口不会出现。这是我点击的图像的代码。你能猜出为什么新的模态窗口没有打开吗?
<input type="image" src="/rhis/images/add2.png" onclick="A4J.AJAX.Submit('modalFormResultPatientSearchPatientSearchForm',event,{'oncomplete':function(request,event,data){Richfaces.hideModalPanel('modalFormResultPatientSearch');},'similarityGroupingId':'modalFormResultPatientSearchPatientSearchForm:patientSearchDataTableId:0:patientContorlsubmitSearch','parameters':{'backingBeanName':'','patientId':'901317','patSearchMrno':'UH0000003923','onPatientSelectCallBack':'','modalFormResultPatientSearchPatientSearchForm:patientSearchDataTableId:0:patientContorlsubmitSearch':'modalFormResultPatientSearchPatientSearchForm:patientSearchDataTableId:0:patientContorlsubmitSearch'} ,'eventsQueue':'modalFormResultPatientSearchsearcha4jQueue'} );return false;" name="modalFormResultPatientSearchPatientSearchForm:patientSearchDataTableId:0:patientContorlsubmitSearch" id="modalFormResultPatientSearchPatientSearchForm:patientSearchDataTableId:0:patientContorlsubmitSearch">
目标模态窗口(未出现)是
<div style="width:100%;" id="opdBrowserEncounterForm:j_id277" class="rich-panel "><div id="opdBrowserEncounterForm:j_id277_header" class="rich-panel-header "><table width="100%"><tbody><tr><td class="alignLeft">Create Encounter</td><td class=" alignRight"><input type="submit" value=" View All"name="opdBrowserEncounterForm:j_id282"></td></tr></tbody></table></div><div id="opdBrowserEncounterForm:j_id277_body" class="rich-panel-body "><div style="display:none;" class="messagePanelInline" id="opdBrowserEncounterForm:encounterMessagesAndErrors"></div>
单击按钮并希望转到目标窗口的Python代码。它点击“找到按钮”并挂起。 : -
element = driver.find_element_by_id('modalFormResultPatientSearchPatientSearchForm:searchTable__patientSearchDataTableId:0:propertyField')
element.send_keys('Patient Name')
element = driver.find_element_by_id('modalFormResultPatientSearchPatientSearchForm:searchTable__patientSearchDataTableId:0:textValueField')
element.clear()
try:
wait = WebDriverWait(driver, 10)
element = driver.find_element_by_xpath('//div[@id="modalFormResultPatientSearchPatientSearchForm:searchTable__patientSearchDataTableId:0:j_id845"]/select[@name="modalFormResultPatientSearchPatientSearchForm:searchTable__patientSearchDataTableId:0:j_id847"]')
except:
driver.quit()
element = driver.find_element_by_id('modalFormResultPatientSearchPatientSearchForm:searchTable__patientSearchDataTableId:0:textValueField')
element.send_keys('Ram Lal')
element = driver.find_element_by_id('modalFormResultPatientSearchPatientSearchForm:searchTable__patientSearchDataTableId:commonSearchButton')
element.click()
try:
element = driver.find_element_by_xpath('//td[span[normalize-space(text())="Ram Lal"]][1]/following-sibling::td[./input[@type="image"]]')
action = ActionChains(driver)
action.double_click(element)
action.perform()
print 'i found the button !'
except:
print 'i did not find the button'
pass