1
      WebDriver driver = new FirefoxDriver();
      driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
      driver.get("http://stackoverflow.com/");
      driver.findElement(By.linkText("log in")).click();
      driver.findElement(By.cssSelector("a.google.openid_large_btn")).click();
      driver.findElement(By.id("Email")).sendKeys("[email protected]");
      driver.findElement(By.id("Passwd")).sendKeys("password");
      driver.findElement(By.id("hlinks-user")).click();
      driver.findElement(By.linkText("user2131252")).click();
      Thread.sleep(3000L);

      // None of these work to click on the upload button , actions, robot..
  //driver.findElement(By.xpath(".//*[@id='change-picture']")).click();
      //Actions actions = new Actions(driver);
      //WebElement changepic = driver.findElement(By.xpath(".//*[@id='change-picture']"));
      //actions.moveToElement(changepic).click().perform();
      //actions.click();
      //actions.perform();

      /*Point coordinates = driver.findElement(By.xpath(".//*[@id='change-picture']")).getLocation();
      Robot robot = new Robot();
      robot.mouseMove(coordinates.getX(),coordinates.getY()+120);
      //robot.mousePress(coordinates.getX());
      driver.findElement(By.xpath(".//*[@id='change-picture']")).clear();
      */

      Actions actions = new Actions(driver);
    //for hovering over the username field
    WebElement menuHoverLink = driver.findElement(By.xpath(".//*[@id='change- picture']"));
    actions.moveToElement(menuHoverLink).perform();
    //for clicking the logout link
    WebElement logoutLink = driver.findElement(By.xpath(".//*[@id='change-picture']"));
    logoutLink.click();

Please I am unable to click on the change-picture link, I get different errors on different browsers.

log4j:WARN No appenders could be found for logger (org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager). log4j:WARN Please initialize the log4j system properly. Exception in thread "main" org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: Element cannot be scrolled into view: (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 13 milliseconds Build info: version: '2.33.0', revision: '4e90c97', time: '2013-05-22 15:33:32' System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_17' Session ID: 4534c06c-0622-4610-8d7d-1cf99f9577ee Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities [{platform=XP, databaseEnabled=true, cssSelectorsEnabled=true, javascriptEnabled=true, acceptSslCerts=true, handlesAlerts=true, browserName=firefox, browserConnectionEnabled=true, nativeEvents=true, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=24.0}] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:191) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554) at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:34) at org.openqa.selenium.remote.RemoteMouse.mouseMove(RemoteMouse.java:88) at org.openqa.selenium.interactions.MoveMouseAction.perform(MoveMouseAction.java:36) at org.openqa.selenium.interactions.CompositeAction.perform(CompositeAction.java:31) at org.openqa.selenium.interactions.Actions.perform(Actions.java:356) at test.stackoverflow.main(stackoverflow.java:52)

1
  • I am unable to click on the 'change-picture' button which inturn brings up the fileupload. All I am trying to do is to upload a picture on my profile. Commented Nov 6, 2013 at 16:16

1 Answer 1

0

you can try using javascriptExcecuter after sleep(),

 ((JavascriptExecutor)driver).executeScript("$('#change-picture').click();");
Sign up to request clarification or add additional context in comments.

3 Comments

above line works on chrome, but on firefox I get an error message. Any thoughts on it?
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: waiting for evaluate.js load failed
Updating to latest Webdriver solves the firefox issue. Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.