selenium - how to upload a multiple images in gmail from web driver -


i'm trying uploading multiple images folder in gmail,does possible in web driver using robot class.

  driver.findelement(by.classname("aot")).click();   driver.findelement(by.classname("aot")).sendkeys("hi");   webelement frame1 = driver.findelement(by.cssselector("div[class='am al editable lw-avf']"));   frame1.click();   frame1.sendkeys("mailbody");   driver.manage().timeouts().implicitlywait(5, timeunit.seconds);     driver.findelement(by.xpath("//div[@class='a1 aaa amz']")).click();     //click on attachment icon         stringselection ss = new stringselection("e:\\cv\\");        //upload file using robotclass        //attach path file located.        toolkit.getdefaulttoolkit().getsystemclipboard().setcontents(ss, null);        robot robot = new robot();        thread.sleep(5000);        robot.keypress(keyevent.vk_control);        robot.keypress(keyevent.vk_v);        robot.keyrelease(keyevent.vk_control);        robot.keyrelease(keyevent.vk_v);        thread.sleep(6000);        robot.keypress(keyevent.vk_enter);        robot.keyrelease(keyevent.vk_enter);        thread.sleep(10000); 

e:/cv---- contains number of file need know select files particular folder. thanks!

yes, it's possible.

  1. you can accumulate file paths of images want upload in array this:

    string arr[] = {"\"d:\\images\\default.jpg\"", "\"e:\\images\\plant4.jpg\"", "\"f:\\jpeg-image.jpeg\""};

    note: image needn't same location

  2. concatenate contents of array of file paths(above) in single string this:

    string arr_final = arr[0];

    for(int i=1;i<arr.length;i++){     arr_final+=arr[i];  } 
  3. put final string parameter while creating object of stringselection class this:

    stringselection ss = new stringselection(arr_final);

now, when string gets pasted in "file name" field of dialog box, represented this:
"d:\images\default.jpg""e:\images\plant4.jpg""f:\jpeg-image.jpeg"

then, when open button gets clicked, concerned images starts getting uploaded.

hope helps..


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -