我想在c#中使用硒web驅動程序上傳文件。 (「C:\ Users \ test \ Desktop \ test.cs」);如果你想要使用它,你可以使用下面的代碼:在c#中使用硒web驅動程序上傳文件#
但這不起作用。
這在硒的webdriver正確硒IDE,但不工作。
以下是網頁的HTML代碼:
,我想使用下列元素:如果您使用的是Firefox瀏覽器,而不是Send keys
使用type
<input class="js-attach-file" type="file" tabindex="-1" name="upload">
<!DOCTYPE html>
<html lang="en">
<head>
<body class="page-index firefox firefox-9 windows extra-large-window full-content window-up">
<div id="nocss">
<div id="surface" class="clearfix" style="height: 725px;">
<div class="window-overlay">
<div class="window" style="left: 375px; top: 50px; display: block;">
<div class="window-wrapper clearfix">
<div>
<div class="window-header-utils">
<div class="window-header clearfix">
<div class="window-main-col">
<div class="window-sidebar">
<div class="window-module card-label-list clearfix hide">
<div class="window-module clearfix">
<div class="window-module clearfix attachments">
<h3>Attachments</h3>
<ul class="attachment-list hide"></ul>
<p class="no-attachments empty">No attachments.</p>
<div class="uploader touch-hide">
<form class="realfile" enctype="multipart/form-data" method="post" action="/api/card/4f701c9daf1765861a15545c">
<input type="hidden" value="" name="token">
<input type="hidden" value="attachFile" name="method">
<input type="hidden" value="http" name="format">
<input class="js-attach-file" type="file" tabindex="-1" name="upload">
</form>
<a class="button-link highlight-icon fakefile js-fakefile">
</div>
<p class="error js-file-too-large" style="display:none; -moz-border-radius: 3px; -webkit-border-radius: 3px; font-weight: bold; margin: 8px 0 0; padding: 6px; background: #e3e3e3; ">File too large. 10mb limit.</p>
</div>
<div class="window-module other-actions clearfix">
<div class="window-module quiet-actions clearfix">
</div>
</div>
</div>
</div>
</div>
<div class="pop-over clearfix fancy-scrollbar" style="display: none;">
<script>
<script src="https://d2k1ftgv7pobq7.cloudfront.net/js/78dcaf5810779a263fe6939fc4895487/all.js">
</body>
</html>
解決這個問題,你是否嘗試「看」硒進程,並檢查什麼真的發生了? – ChrFin 2012-03-26 07:38:51
是的,我嘗試過......但實際上沒有東西.......我無法理解硒在做什麼........在源代碼中獲取硒...... ...上傳按鈕可用...讓我知道你是否想要更多的信息.........謝謝。 – Ramesh 2012-03-26 09:18:31
硒究竟做了什麼或不做什麼?它是否進入路徑?它是否開始上傳?它是否會在硒rc中發生任何錯誤? – ChrFin 2012-03-26 09:36:55