C# Selenium文件上载不工作
我正在尝试通过Selenium上传简历。 我在“添加文件”和“上传”页面上有两个按钮 Html:C# Selenium文件上载不工作,c#,selenium-webdriver,C#,Selenium Webdriver,我正在尝试通过Selenium上传简历。 我在“添加文件”和“上传”页面上有两个按钮 Html: 试试这个:在SendKeys我试过但不起作用后,你不需要点击上传按钮。问题是,当我单击“选择文件”时,上载对话框会打开。发送密钥后,“添加文件”按钮看起来已禁用,因此我需要单击某个按钮来关闭对话框。我无法控制html代码,因此无法更改它的工作方式。 <input type="file" name="uploadedfile" aria-labelledby="Uploader_0_label"
试试这个:在SendKeys我试过但不起作用后,你不需要点击上传按钮。问题是,当我单击“选择文件”时,上载对话框会打开。发送密钥后,“添加文件”按钮看起来已禁用,因此我需要单击某个按钮来关闭对话框。我无法控制html代码,因此无法更改它的工作方式。
<input type="file" name="uploadedfile" aria-labelledby="Uploader_0_label" accept=".doc, .docx, .pdf, .html, .htm, .wks, .txt" style="position: absolute; font-size: 2em; top: -3px; right: -3px; cursor: pointer; opacity: 0;" tabindex="-1" aria-disabled="false"/>
"<span id="Button_9_label" class="dijitReset dijitInline dijitButtonText" data-dojo-attach-point="containerNode">Upload</span>"
string newPath = filepath.Replace("\\\\","\\");
Driver.FindElement(By.XPath("//input[@name='uploadedfile' and @type='file']")).SendKeys(newPath);
Driver.FindElement(By.XPath("//span[text()='Upload']")).Click();