user3680001
user3680001

Reputation: 91

Image upload functional testing in Geb

When i am testing the image upload in Geb ,how i click the Open option when we have to select image from the system My code is:

class UploadImageTestSpec extends GebReportingSpec{

def "test for UploadImage"()
{
    when:
    to LandingPage
    waitFor(20) {title.endsWith("Jobulo")}
    loginButton.click()
    j_username="candidate2"
    j_password="p"
    login.click()
    then:
    at DashBoardPage
    when:
    at DashBoardPage
    waitFor(20) {title.endsWith("Jobulo")}
      uploadImage.click()
     // uploadImage1.click()
    Thread.sleep(1000)
      //new File(".").getAbsolutePath().replace("..","");
   // cd=new File(".").getAbsolutePath().replace("..",""); + "images.jpeg"

    driver.manage().timeouts().implicitlyWait(200,TimeUnit.SECONDS)
    crop.click();
    then:
    at DropDownPage
}
}

Upvotes: 3

Views: 1676

Answers (1)

Lalit Agarwal
Lalit Agarwal

Reputation: 2354

It is not possible to do image upload using geb.

Refer this link: http://www.gebish.org/manual/current/#file-upload

It’s currently not possible with WebDriver to simulate the process of a user clicking on a file upload control and choosing a file to upload via the normal file chooser. However, you can directly set the value of the upload control to the absolute path of a file on the system where the driver is running and on form submission that file will be uploaded.

<input type="file" name="csvFile">

$("form").csvFile = "/path/to/my/file.csv"

-- From the link

Upvotes: 1

Related Questions