0
對於我的生活,我無法控制這種模式中的任何東西。我只想點擊這個dang保存按鈕。Seleium/Ruby - 無法訪問保存按鈕在模式彈出
對於這一切都是這樣我能夠成功使用該代碼的其他情態動詞:
@driver.switch_to.frame @driver.find_element(:xpath, "//*[contains(@name, 'modal')]")
我得到一個未找到錯誤,這一次雖然。
這裏的模式我試圖訪問的HTML - 音符的衆數的變化,所以我不能硬編碼modal3:
和這裏的按鈕的HTML:
<html class=" ext-strict">
<head>
<body class=" ext-gecko ext-gecko2" keydownhandlerset="true">
<div id="patientChartsContainer">
<div id="patientSearch" style="display:none">
<div class="tooltipWrapper">
<div id="patientPhotoContainer"></div>
<div id="modalWindowContainer" class="">
<div class="axShadowLayer window local" style="display: block; width: 558px; height: 453px; left: 384px; right: auto; top: 228px; z-index: 1010;">
<div class="axShadowTopRow">
<div class="axShadowMiddleRow">
<div class="axShadowBottomRow">
<div class="axShadowContentLayer">
<div class="priModalWrapper">
<ul class="priModalHeader">
<div class="priModalContentBackground"></div>
<ul class="priModalFooter">
<div class="priModalContentWrapper">
<div class="priModalContentContainer">
<iframe id="modal1" class="windowFrame" name="modal1" src="/chart/ui/desktop/patientCharts/chartSummary/chartNote/createChartNote/createNoteModal.html" allowtransparency="true" frameborder="0">
<!DOCTYPE html>
<html class=" ext-strict" xmlns="http://www.w3.org/1999/xhtml">
<head>
<body class=" ext-gecko ext-gecko2" keydownhandlerset="true">
<div id="newNoteContainer" class="newEncounterNote">
<ul class="newNoteOptions">
<div class="axModalButtonsFooter">
<div class="footerButtonsWrapperRight">
<div class="buttonClass axSaveButton">
<span>Save</span>
我已經試過什麼,我有以下幾件事情和變化:
#@driver.find_element(:xpath, "//div[@id='modalWindowContainer']/div/div[4]/div/ul/li/div[2]/div[3]").click
#@driver.switch_to.frame @driver.find_element(:xpath, "//*[contains(@name, 'modal')]")
#@driver.switch_to.default_content
#@driver.switch_to.frame(@driver.find_element(:class, 'windowFrame'))
#@driver.find_element(:css, "div.buttonClass.axSaveButton").click
#@driver.switch_to.frame @driver.find_element(:class, 'windowFrame')
#@driver.find_element(:xpath => "//button/span[contains(text(),'Save')]").click
/HTML /體/ DIV 1/DIV/DIV/DIV/SPAN
不幸的是沒有工作。錯誤:test_CreateAndVerifyPatient(Createnewpatient):Selenium :: WebDriver :: Error :: NoSuchElementError:無法找到元素:.windowFrame – Jen
打開iframe後是否執行給定行? 如果是這樣,你是否嘗試添加'when_present'條件? 來源:http://www.seleniumframework.com/basic-tutorial/wait_commands/ –
打開框架後,我確實執行了給定的行,這是一個很好的想法,但不幸的是我仍然得到錯誤:test_CreateAndVerifyPatient(Create newpatient): Selenium :: WebDriver :: Error :: NoSuchElementError:no such element:Unable to locate element:{「method」:「css selector」,「selector」:「buttonClass.axSaveButton> span」}會話信息:chrome = 55.0。 2883.87) – Jen