[英]failed to upload a file using selenium webdriver in Java
我正在嘗試使用Selenium Webd River上傳文件,但無法使該Spinet代碼正常工作
driver.findElement(By.id("uploadForm:j_id135")).sendKeys("path_to_file");
driver.findElement(By.name("uploadForm:j_id139")).click();
我也嘗試過以下建議: 使用Selenium WebDriver和Java進行文件上傳對我來說太糟糕了
有什么想法嗎?
當您手動單擊以上傳文件時(在手動工作時),將提供實際輸入框(提供路徑的位置)的“ id”。 在自動化方案中,我們需要使用以下命令來提供該輸入框的正確ID:
driver.findElement(By.id(“ upload”))。sendKeys(“ / path / to / the / file”);
下一步當然是單擊“上傳”按鈕。
如果您使用的是WebDriverBackedSelenium,則可以使用:
selenium.type(“ locator”,“ / path / to / the / file”);
selenium.click(“ upload_button”);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.