OS按鈕:OSX的MacOS塞拉利昂10.12.6無法點擊置於iframe內的Safari瀏覽器與硒
硒版本:3.6.0
瀏覽器:Safari瀏覽器
瀏覽器版本: 11.0.1(12604.3.2)
預期行爲 - 點擊()行爲應在位於Safari瀏覽器的iframe中的按鈕工作
實際行爲 - 無在Safari瀏覽器中操作時執行button.click()動作
步驟來重現 -
- 打開Safari瀏覽器
- 訪問Web應用程序登錄屏幕
- 輸入有效的憑據,點擊登錄按鈕,彈出最多出現
- 切換到iframe的
- 點擊按鈕放在一個iframe
單擊按鈕時無動作。相同的代碼在其他瀏覽器(瀏覽器,Mozilla,IE11)
下面做工精細是代碼:
SafariOptions options = new SafariOptions();
options.setUseCleanSession(true);
driver = new SafariDriver(options);
driver.manage().window().maximize();
driver.get("testurl");
driver.findElement(By.id("UN")).sendKeys("admin");
driver.findElement(By.id("UN")).sendKeys("admin$");
driver.findElement(By.id("Login")).click();
driver.switchTo().frame(driver.findElement(By.xpath("//*[starts-with(@class,'dijitDialog') and contains(@style,'z-index: 950;')]//*[starts-with(@id,'AxDojo_Dialog_frame')]")));
driver.findElement(By.xpath("//*[@id='ButtonPlaceHolder']/button[2]")).click();
在執行最後一步沒有動作。 作爲變通發現下面的代碼
driver.findElement(By.xpath("//*@id='ButtonPlaceHolder']/button[2]")).sendKeys(Keys.ENTER);
執行點擊按鈕的替代,但像這樣的,我們需要在很多方面改變,硒是獨立於瀏覽器和維護代碼的瀏覽器的聰明是單調乏味的任務給我們。請任何人都可以看看這個問題。
請在iframe中查找HTML代碼。
<iframe id="AxDojo_Dialog_frame_1508320744505" name="AxDojo_Dialog_frame_1508320744505" style="border: 0px; width: 605px; height: 159px;" width="605" height="136px" scrolling="auto" frameborder="0" src="about:blank" axpageload="1"></iframe>
#document
<!DOCTYPE html>
<html style="overflow-y: hidden"><head>
<title>Login</title>
<link href="../AxCommon/Styles/ECDefault/main.css" type="text/css" rel="stylesheet">
<script language="javascript" type="text/javascript" src="../Packages/Scripts/JQuery/jQuery.js"></script>
<script type="text/javascript" language="javascript" src="../AxCommon/Scripts/AxSystemBroadcast.js"></script>
<script type="text/javascript" src="../AxCommon/Scripts/AxMyParent.js"></script>
<script type="text/javascript" src="./Scripts/AxDialog.js?v=14082015"></script>
<style type="text/css">
.DialogBtn{width: 80px; font-size: 10pt;white-space:nowrap;}
.DialogCustomBtn{font-size: 10pt;white-space:nowrap;}
#popupMandatoryDiv { display:none;position:relative;height:auto;background:#FFFFFF;z-index:999999;overflow:auto;border:1px solid black;padding:5px 20px 10px 18px;font-size:12px;}
li {list-style: none; }
/*li:before {content:'\2022'; display: block; position: relative; max-width: 0px; max-height: 0px; left: -13px; top: -4px; color: red; font-size: 20px;padding-right: 5px;}*/
li:before {content:'\2217'; display: block; position: relative; max-width: 0px; max-height: 0px; left: -13px; top: -2px; color: red;font-weight:bold}
</style>
</head>
<body>
<div id="divMask" style="height: auto; width: auto;">
<table id="Table1" cellspacing="6" cellpadding="4" border="0">
<tbody><tr>
<td rowspan="3" style="width: 3px; height: 5px" valign="top" align="center"></td>
<td colspan="2" valign="top" align="center" height="10"></td>
</tr>
<tr style="width:100%">
<td valign="top" align="center" width="10%">
<img id="IconImage" src="../AxCommon/Images/28 information.gif">
</td>
<td valign="middle" align="left" height="5" width="90%">
<div id="divPrompt" align="left" style="DISPLAY: block; FONT-SIZE: 9pt; OVERFLOW: hidden; DIRECTION: ltr;">You are already logged into Excelicare in other active session(s). Please choose one of the options below:</div>
</td>
</tr>
<tr style="width: 100%; display: none;">
<td valign="top" align="center" width="10%">
</td>
<td valign="top" align="left" height="5" width="90%">
<div id="popupMandatoryDiv" align="left" style="DISPLAY: block; FONT-SIZE: 9pt; OVERFLOW: auto; DIRECTION: ltr;display:none">
</div>
</td>
</tr>
<tr>
<td valign="middle" align="center" colspan="2" style="padding-top: 10px">
<div id="ButtonPlaceHolder"><button class="DialogCustomBtn" onclick="AxSysF_CloseWindow(6)">Open new session/<br>end other session(s)</button>
<button class="DialogCustomBtn" onclick="AxSysF_CloseWindow(7)">Open new session/<br>retain other session(s)</button>
<button class="DialogCustomBtn" onclick="AxSysF_CloseWindow(0)">Cancel login<br> </button> </div>
</td>
</tr>
<tr id="trchkPlaceHolder" style="visibility: hidden; display: none;">
<td> </td>
<td valign="middle" align="left" colspan="3" id="tdchkPlaceHolder">
<div id="checkPlaceHolder"></div>
</td>
</tr>
</tbody></table>
<div>
<br>
<div id="lblInfo" style="display: block;"><b>Note : </b> If you choose to <i>Open new session/end other session(s)</i> any unsaved data in the other session(s) will be lost.</div>
</div>
</div>
<input id="hdnTitle" type="hidden" value="Login">
<script type="text/javascript">
var strProductType = '<%=System.Configuration.ConfigurationSettings.AppSettings("ProductType")%>';
strModulePageName = 'frmdialog';
$(document).ready(function() { PageLoaded();setTimeout('self.focus()', 10);});
function setCallback(CallbackFn) {
_CallbackFn = CallbackFn;
}
document.oncontextmenu = function (event) {return false;};
</script>
</body></html>
您可以擴展我們感興趣的'
我想這是關於Safari私人模式的安全策略。你可以用Safari私人模式打開你的網站,看看Develop> JavaScript Console?有沒有錯誤? – Buaban
@DebanjanB我在我的問題中添加了HTML代碼片段,並共享了另一個屏幕截圖,擴大了標記。請找到詳細信息。 –
SeJaPy