WebDriver Selenium browse file Java

Vitaliy Mckay

Can't browse file using webdriver.

driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
driver.findElement(By.id("1434461513889_57_7_input.file")).sendKeys("C:\\PDF_V1_COL88810_6L_Frangipani_TL_Fr_P1211089.pdf");

Have this error:

NoSuchElementException: Unnable to locate element: {"method":"id","selector":"BatchUploadPlugin_57_fileupload"}

HTML code

Subh

From the screenshot you have given, I can see the concerned element is in an iframe.

(Check the second bar in the developer tools below the bar containing: Inspector, Console,etc. You will note the iframe#iframe_1434526152814_57_7. ).

Hence, you weren't able to send the path to it.

In order to send the path for upload, you need to switch to the frame first and then send the path to the element "Browse" for upload.

For switching frame, you can use the below code (The frame id that I can see from the screenshot, is iframe_1434526152814_57_7 which I can safely presume to be dynamic and can't use as ID of the frame to switch-to. So, I am assuming there is only 1 frame in the page, hence the code.):

driver.switchTo().frame(0);

Then, send the path to the element using the below code:

driver.findElement(By.xpath("//input[@name='userfile']")).sendKeys("C:\\PDF_V1_COL88810_6L_Frangipani_TL_Fr_P1211089.pdf");

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Selenium 2 WebDriver UnhandledAlertException Java

分類Dev

Selenium WebDriver Java cssSelector Span

分類Dev

Choose file without using browse in android java

分類Dev

Selenium Webdriver using Ruby: write text to file

分類Dev

Java8とSelenium WebDriver

分類Dev

Selenium Webdriver Java:Element Not Visible Exception

分類Dev

How to find an Element by index in selenium webdriver for java

分類Dev

How to launch Safari with Selenium WebDriver using Java

分類Dev

Selenium Webdriver (Java) - using AND/OR conditions in XPATH

分類Dev

Selenium WebDriver java.lang.NullPointerExceoption

分類Dev

How to select many files using Windows file explorer with selenium webdriver

分類Dev

Java POMクラスのSelenium WebDriver NullPointer例外

分類Dev

WebdriverIO対Selenium Webdriver(Javaアプローチ)

分類Dev

JavaScriptをSelenium WebDriver Javaで使用する方法

分類Dev

JavaでSelenium WebDriverを使用する

分類Dev

Reuse Selenium WebDriver Session When Restarting Java Application

分類Dev

Primefaces selectOneMenu with Selenium webdriver does not select the item + Java

分類Dev

How would I interact with this input box in Selenium Webdriver using Java?

分類Dev

How to find specific table element with selenium webdriver in java?

分類Dev

Selenium Webdriver assert 2 elements contains same number in Java

分類Dev

Python Selenium Chrome Webdriver

分類Dev

Selenium WebDriver StaleElementReferenceException

分類Dev

Selenium Safari WebDriver Not Working

分類Dev

Selenium IE WebDriver:NoSuchElementException

分類Dev

Selenium Webdriver give NoSuchFrameException

分類Dev

Selenium Webdriver python storeTextPresent

分類Dev

selenium js webdriver.By

分類Dev

Javaを使用したSelenium WebDriver(Selenium 2)のselenium.refresh()の同等のコード

分類Dev

What will be the Selenium WebDriver Script for direct drag file from local drive and Drop it to web app?

Related 関連記事

  1. 1

    Selenium 2 WebDriver UnhandledAlertException Java

  2. 2

    Selenium WebDriver Java cssSelector Span

  3. 3

    Choose file without using browse in android java

  4. 4

    Selenium Webdriver using Ruby: write text to file

  5. 5

    Java8とSelenium WebDriver

  6. 6

    Selenium Webdriver Java:Element Not Visible Exception

  7. 7

    How to find an Element by index in selenium webdriver for java

  8. 8

    How to launch Safari with Selenium WebDriver using Java

  9. 9

    Selenium Webdriver (Java) - using AND/OR conditions in XPATH

  10. 10

    Selenium WebDriver java.lang.NullPointerExceoption

  11. 11

    How to select many files using Windows file explorer with selenium webdriver

  12. 12

    Java POMクラスのSelenium WebDriver NullPointer例外

  13. 13

    WebdriverIO対Selenium Webdriver(Javaアプローチ)

  14. 14

    JavaScriptをSelenium WebDriver Javaで使用する方法

  15. 15

    JavaでSelenium WebDriverを使用する

  16. 16

    Reuse Selenium WebDriver Session When Restarting Java Application

  17. 17

    Primefaces selectOneMenu with Selenium webdriver does not select the item + Java

  18. 18

    How would I interact with this input box in Selenium Webdriver using Java?

  19. 19

    How to find specific table element with selenium webdriver in java?

  20. 20

    Selenium Webdriver assert 2 elements contains same number in Java

  21. 21

    Python Selenium Chrome Webdriver

  22. 22

    Selenium WebDriver StaleElementReferenceException

  23. 23

    Selenium Safari WebDriver Not Working

  24. 24

    Selenium IE WebDriver:NoSuchElementException

  25. 25

    Selenium Webdriver give NoSuchFrameException

  26. 26

    Selenium Webdriver python storeTextPresent

  27. 27

    selenium js webdriver.By

  28. 28

    Javaを使用したSelenium WebDriver(Selenium 2)のselenium.refresh()の同等のコード

  29. 29

    What will be the Selenium WebDriver Script for direct drag file from local drive and Drop it to web app?

ホットタグ

アーカイブ