How to send data without using sendKeys in Selenium?

Can we do file upload through Selenium?

I am automating a web application using Selenium.

In that I need to upload a file (pdf) from one page to another in the same application.

My question is can we upload a file through Selenium? I am able to upload files through File Upload control of asp.net.

But when I am trying to automate it in Selenium I am getting below error. Org.openqa.selenium.WebDriverException: unknown error: Unable to find element with locator: By.

. . . . . . .
.
. I was able to do so by providing the "name" attribute for the file upload element. In my case, the file upload element had name attribute as "fileUpload1". This needs to be provided in order to send a file to server.

Hence I have changed my code to look like below. Driver.FindElement(By.Name("fileUpload1")).

How to send data without using sendKeys in Selenium?

I have two textboxes in the form and want to enter data in them without using SendKeys in Selenium.

I used sendKeys method, but it does not work.

I am sending keys to web elements from Java code, and it is working on Firefox. However, it doesn't work on IE and Chrome browsers.

The code I am using to send keys is like this. Public void clickOnSubmitButton(). }

If someone can help me it would be really helpful, thanks! This works just fine, I tested on latest version of chrome, firefox and IE 11, all were able to do it. You only need to call .click() once as the javascript runs async and calls the click() method after you have passed your command into the WebDriver instance.

You also could do with some of the wait methods (ie. Time out) however, you could also call .sendkeys() and .sendkeys(Keys.Enter) etc if you wish.

How to upload file without input in Selenium?

Hi all!

I am using Selenium RC/Selenium2.0 in our project.

There is one form which has input box and a file upload to submit this data. When users want to submit data, they need to enter the input input box, also they have to select files from any location. But as soon as users choose a file in "open file dialog" and then selects "save" button, form submitting will be happened. Users will no need to do anything in selecting file.

I am newbie to Selenium and I don't know how I can write this script. Anybody know this problem? It's very basic concept. Just open the browser window with given URL and wait for the element (input or file field) appears, and after that just type text there and press save. I don't know which OS you are using but I suppose that all browsers supports waiting for new windows to appear. You could try something like this:
Driver.get(""); while(!isElementPresent()). Driver.findElement(By.id("lst-ib")).sendKeys("inputText");
Driver.findElement(By.id("searchbox")).sendKeys("inputText");
Driver.findElement(By.id("btnG")).click();

And then you'll have new window in browser and the file input element appeared already filled with text string (inputText value).

Related Answers

How can we use the Selenium tool with HeadSpin?

Selenium is a tool that is used to automate functional testing. There are two types...

What are 5 Uses of Selenium?

Selenium is a web-automation tool that helps you to test web applications....

How can we use the Selenium tool with HeadSpin?

Selenium is a cross-browser testing automation framework w...