I am automating a test case for application where you have to set by uploading from your desktop. I have used Actions class because previously I was using simple SendKeys but it threw “Cannot focus element exception”.
Now using Actions class, it clicks on the button and opens windows up but it does not get the path of the image that I have given. up is displayed and then nothing happens
This is my code:

@Test
public void f() throws InterruptedException {

  //Search Patient
  DDriver.findElement(By.id("patientsFilterButton")).click();
  Thread.sleep(3000);

  //Search a patient by First Name
  DDriver.findElement(By.id("patientFirstName")).click();
  DDriver.findElement(By.id("patientFirstName")).sendKeys("Patient");
  Thread.sleep(1000);
  DDriver.findElement(By.id("searchPatientButton")).click();
  //Select patient
  DDriver.findElement(By.id("patientInfo_285051")).click();
  //Enter Group name
  DDriver.findElement(By.id("groupName")).click();
  DDriver.findElement(By.id("groupName")).sendKeys("This is automated group");
  // Group image
  Actions actions = new Actions(DDriver);     
  WebElement element = DDriver.findElement(By.id("changePicSpan"));
  actions.moveToElement(element);
  actions.click();
  actions.sendKeys("C:\doc.jpg");
  actions.perform();
  Thread.sleep(5000);



Source link https://sqa.stackexchange.com/questions/35133/web--upload-an-image-from-pop-up-box-in---

LEAVE A REPLY

Please enter your comment!
Please enter your name here