I am running a selenium webdriver script headless using Phantomjs Driver. I am having issues uploading a file though since on a normal browser (firefox or chrome) it would pop up the OS dialog box that would allow me to locate the file in my machine and upload it. How to do that with the ghostDriver (Phantomjs Driver)? Thanks
相关问题
- Selecting an item from a combo box selenium driver
- Selenium in Java is not finding element when using
- How to send text to the search field through Selen
- What is the difference in “find_element_by_xpath”
- Cloudflare and Chromedriver - cloudflare distingui
in the new version of phantomjs, you can upload file like this uploadfile
Always identify & interact with elements of type "file" when uploads are concerned. This would solve your issue of pop ups.
Ex: In my application, upload related elements have the below DOM -
In this case, you can use sendKeys method to "multiFileInput" which is of type "file". This way it would work for all FF, Chrome & also headless browsers.
This code helped me with uploading if 'multiple' attribute was set:
I am having the same issue and have posted a question for the same. PhantomJS hangs up when using sendKeys() method.
They have an issue logged here - https://github.com/ariya/phantomjs/issues/10993
One of the comments on the issue stated that the below statement worked -
You may try the above solution, but it may or may not work.