Quality Testing

Quality is delighting customers

I have a scenario where I need to click on the Upload CSV File button and insert a filename in EDGE browser.

I am facing the issue as Below:

When I click on the  Upload CSV File button the windows control opens up as shown below:

When this windows control opens up the Auto IT is not working.

AutoIT Script:
ControlFocus("Open","","Edit1")
ControlSetText("Open","","Edit1","C:\Users\Desktop\AutoIT\upload.png")
ControlClick("Open","","Button1")

But If I ran the autoit exe manually works fine in this case.

Do please help me out on this.

Thanks in Advance

Views: 91

Reply to This

Replies to This Discussion

I wouldn't recommend going for AutoIT as it will require the browser constantly being in focus therefore you will not be able to do anything else while your test is running. Moreover when you will be running your tests using Selenium Grid in parallel you will face issues. 

Therefore you can just locate the relevant <input type="file"> element and invoke sendKeys( ) function providing the full path to the file you're trying to upload. 

Relevant code:

driver.findElement(By.xpath("//input[@type='file'")).sendKeys("C:\\Users\\Desktop\\AutoIT\\upload.png");

More information: How can I work with file uploads during a Webdriver test?

Hi Dmitri,

Thanks for your quick reply. 

I have tried with sendkeys, it is giving me below error. 

Error:

org.openqa.selenium.WebDriverException: The element is not focusable (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'

Driver info: org.openqa.selenium.edge.EdgeDriver
Capabilities {InPrivate: false, acceptSslCerts: true, applicationCacheEnabled: true, browserName: MicrosoftEdge, browserVersion: 42.17134.1.0, javascriptEnabled: true, locationContextEnabled: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, platformVersion: 10, takesElementScreenshot: true, takesScreenshot: true, webStorageEnabled: true}

My Code:

WebElement upload = driver.findElement(By.xpath("//input[@id="upload"]");

upload.sendKeys("C:\\images\\im.png");

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2019   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service