2

I am using eclipse Helios Version: Helios Service Release 1,Build id: 20100917-0705 with selenium 3.141.59 but when I am trying to use this sendKeys() function then it is showing error message:

The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files

The Source code is:

package AutomationFramework;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.By;
//import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
//import org.openqa.selenium.Alert;
//import org.openqa.selenium.WebElement;


public class HandleFileupload {

    public static WebDriver driver = null;
    
    public static void main(String[] args) 
    {
    
        System.getProperty("webdriver.chrome.driver","G:\\chromedriver.exe");
        driver = new ChromeDriver();
        driver.get("https://html.com/input-type-file/");
        driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS );
        driver.manage().window().maximize();
        driver.findElement(By.xpath("//*[@id='fileupload']")).sendKeys("filupload");
                
    }

}
9
  • Show the code please
    – PDHide
    Mar 28, 2020 at 7:49
  • It seems like the issue usually occurs when you have different jdk and jre version . Endure that both jdk and jre are of same java version
    – PDHide
    Mar 28, 2020 at 7:55
  • Please send me step by step installation of selenium web driver with proper versions. i think there is some problem in my software or jar files. i don't know how would i check whether my java environment is set up correctly or my class & file name is same or not Mar 28, 2020 at 9:51
  • run java --version and javac --version in cmd
    – PDHide
    Mar 28, 2020 at 18:22
  • 1
    I have installed eclipse photon version and selenium standalone server and now everything is working fine. Thanks for your support Mar 29, 2020 at 10:32

4 Answers 4

1

From the sample code it can be seen that you are trying to pass file name for a file upload (<input type="file">) element.

driver.findElement(By.xpath("//*[@id='fileupload']")).sendKeys("filupload");

You need pass the full path of the file that you want to upload in the above line.

So the change in your code would look something like this,

driver.findElement(By.xpath("//*[@id='fileupload']")).sendKeys("C:\\\\Users\\Achint\\Desktop\\Files\\Filename.txt");

This should work out for you.

0

I think you use sendkeys command for File upload button

driver.findElement(By.xpath("//*[@id='fileupload']")).sendKeys("filupload");

pass file path to sendkeys parameter and try

0

In software testing companies different types of testing services are provided by qa engineers like security testing services etc.

In the above scenario, when we are uploading any file using Selenium whose fileupload button id = 'fileupload', Then we have to pass file path to the 'SendKeys' function.

0

In Software qa services we can do by multiple ways. By selenium in above code we need to update the line to : driver.findElement(By.xpath("//*[@id='fileupload']")).sendKeys("locationofTheFilePlaced"); in locationofTheFilePlaced please add the location of the file present in the framework. Moreover we can achieve this using the AutoIT. Please refer below link for the details upload of file using AutoIT. https://www.softwaretestinghelp.com/file-upload-in-selenium/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.