我試圖使用Selenium WebDriver
上傳文件。問題是硒沒有發送文件路徑到對話窗口。我正在使用SendKeys()
。這裏是我的代碼:使用Selenium WebDriver上傳文件 - 無法與對話框窗口交互C#
Click.DsrSubmitNewActivityToolPage.AttachmentButton();
Thread.Sleep(4000);
Actions action = new Actions(PageElements.Driver);
action.SendKeys("C:/Users/gk/Documents/Test/Test Test.docx");
action.SendKeys(Keys.Enter);
Thread.Sleep(4000);
這裏是HTML:
<div class="activity yui3-g">
<div class="label yui3-u-1-5">
<span>Attachment:</span>
</div>
<div class="yui3-u-4-5">
<input id="fileID" type="file" name="file"/>
</div>
</div>
<div id="pointValueContainer" class="activity yui3-g" style="display:none">
<span class="label">Notes</span>
<div class="activity">
<p>
你能提供'html'嗎? – Saifur 2015-02-11 17:50:24
@Gala_De你缺少'.Perform()'方法調用來完成操作。 – 2015-02-11 18:05:38
感謝您的回覆@Vivek Singh。爲了您的方便,我附上了html。 – 2015-02-13 22:05:20