1

I have a problems with the file upload through Selenium RemoteWebDriver(chrome driver, up using selenium grid).

Similar to this thread: Sending Keys to Input WebElement fails as it is not an absolute path

Done some research and seems like that solution works. However, i'm getting this error: Cannot resolve method 'setFileDetector(org.openqa.selenium.remote.LocalFileDetector)'

I did have a required imports. Here is my remote webdriver setup method:

public WebDriver SetupRemoteChromeDriver(){

Integer pageTimeout = 50;


final DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setJavascriptEnabled(true);
capabilities.setCapability("acceptSslCerts",true);
capabilities.setCapability("cssSelectorsEnabled", false);
capabilities.setCapability("applicationCacheEnabled", true);
capabilities.setCapability("handlesAlerts", true); //this is new to try
capabilities.setCapability(CapabilityType.BROWSER_NAME, "chrome");

WebDriver browser = null;
try {
    browser = new RemoteWebDriver(
            new URL("http://*ip*:4444/wd/hub"),
            capabilities
    );

    //File upload issue specific to chromedriver
    browser.setFileDetector(new LocalFileDetector());
} catch (MalformedURLException e) {
    e.printStackTrace();
}


browser.manage().timeouts().pageLoadTimeout(pageTimeout, TimeUnit.SECONDS);
browser.manage().timeouts().setScriptTimeout(pageTimeout, TimeUnit.SECONDS);
browser.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

return browser;
}

imports to that class:

import com.gargoylesoftware.htmlunit.BrowserVersion;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.SystemUtils;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.openqa.selenium.*;
import org.openqa.selenium.remote.*;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriverService;


import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.concurrent.TimeUnit;

selenium version: 2.53.1 According to the docs https://seleniumhq.github.io/selenium/docs/api/java/ RemoteWebDriver class must have that method. Any idea why it's not imported?

1
  • yes i tried to add that, but anyway the setFileDetector is a method from the RemoteWebDriver class. Nov 13, 2016 at 12:58

1 Answer 1

3

I think you need to change line WebDriver browser = null; to RemoteWebDriver browser = null;. The variable browser is defined with type WebDriver which does not have the specified method.

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.