Issue
I'm unable to control chrome file-upload window in selenium, so I use pyautoit, this works fine in desktop mode, but I need it to run in a headless linux container.
Is there any way to control it in headless mode? (its a single page app with a complex upload script I haven't figured out the internal post to work, hoping I can bypass it with selenium).
webdriver.find_element(By.XPATH, "//label[@class='button']").click()
time.sleep(2.0)
autoit.win_wait_active("Open", 5)
autoit.send(fname)
autoit.send("{ENTER}")
I'm using python 3.10.4, selenium 4.1.3
Solution
Usually Button specified for browsing the file from Local system has the xpath as //input[@type='file']
You can use this xpath to send keys the local path
webdriver.find_element(By.XPATH, "//input[@type='file']").send_keys("Your Local path")
For best practice you should store your file to be uploaded in your git repository and provide git clone path/git repository path where your file is located.
The below example in Java.
eg.System.getProperty("user.dir")+"\\"+"src/test/resources/TestData/Input/"+"yourFile"
Answered By - Sonali Das
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.