我正在使用PowerShell解決方案來在SharePoint(2013)網站設置中刮一些頁面,並且我一直在關注如何引用在刮擦過程中彈出的ModalDialog 。任何建議如何做到這一點?如何使用PowerShell在Internet Explorer中刮取模態對話框
我期待從輸入框中提取數據,然後單擊「取消」返回上一頁。
調用模式的鏈接是:
<td class='ms-authoringcontrols'>
<table cellspacing='0' cellpadding='0' border='0' class='ms-authoringcontrols'>
<a id="ctl00_PlaceHolderMain_editBB1" onclick="OpenBestBet('https:\u002f\u002www.example.com\u002fsites\u002fusa\u002fproductqualitysupport\u002fPages\u002fdefault.aspx'); return false;" href="#BestBet">Edit</a>
</table>
</td>
打開的modaldialog的JS功能是:
function OpenBestBet(bestBetUrl)
{
// make up the url to send to the BestBet page
bestBetUrl = bestBetUrl?escapeProperly(bestBetUrl):bestBetUrl;
var addedBestBets = document.forms[0].elements['ctl00_PlaceHolderMain_bestBet'].value ;
var keyword = escapeProperly(document.forms[0].elements['ctl00_PlaceHolderMain_keyword'].value);
var gotoUrl =
addQueryParametersToUrl('BestBet.aspx',['u','k','a'],[bestBetUrl,keyword,addedBestBets]);
var dialogOptions = {width:500, height:450};
SP.SOD.executeFunc('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', function() { SP.UI.ModalDialog.commonModalDialogOpen(gotoUrl,dialogOptions,AddBestBetCallback,[addedBestBets]); });
}
這就是它看起來像在頁面上:
模態對話框的主體標籤以:
<body>
<form method="post" action="BestBet.aspx?u=https%3a%2f%2fwww.example.com%2fsites%2fusa%2fproductsupport%2fPages%2fdefault.aspx&k=PQSS&IsDlg=1" onsubmit="javascript:return WebForm_OnSubmit();" id="BestBet">
<div class="aspNetHidden">
<input type="hidden" name="__REQUESTDIGEST" id="__REQUESTDIGEST" value="0xOBFUSCATED,29 Aug 2014 20:57:46 -0000" />
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/OBFUSCATED=" />
</div>
<script type="text/javascript">
//<![CDATA[
我使用PowerShell 3.0,Net.WebClient,application.internetexplorer對象,也有HtmlAgilityPack,但我無法弄清楚如何引用modaldialog。任何幫助都會變得更好!謝謝
您可能想要檢查使用硒 http://www.seleniumhq.org/download/ – 2014-08-30 20:54:21
起初我不願意使用Selenium,因爲學習曲線,它在PowerShell和MSIE之外,我是主要用於這項任務。但我決定嘗試一下,認爲Selenium會公開一種從PS訪問模式窗口的方式。 Selenium能夠導航到頁面,打開模式並關閉它,但是我不清楚如何在PS中使用模式窗口。有什麼建議麼?我也想弄清楚如何讓Selenium完成全面的Scrap並輸出到XML文檔的CSV。我也很感激這方面的任何指示。 – MJA 2014-09-10 19:08:06