Mehmet Fatih

Mehmet Fatih

  • 804
  • 923
  • 31.9k

Changing the image on the website to a new one with selenium

Jan 9 2024 9:06 PM

I want to replace a person's picture in a certain folder with a new one using Selenium. How can I select the picture according to the person's information by pressing the upload button under the picture and replace it with a new one? In my codes, it constantly clicks on the upload button and does not upload by selecting the image.

var FilePath = System.Windows.Forms.Application.StartupPath + "\\resimler\\ " + jpgname + ".jpg";
Actions actions = new Actions(drv);
WebElement uploadPhotoBtn = (WebElement)drv.FindElement(By.XPath("//*[@id=\"flResimSec\"]"));
actions.MoveToElement(uploadPhotoBtn).Click().Perform();

 


Answers (12)