How to upload a file using webdriver


Solution: Dealing with Dialog Box:

magic 1:

driver.findElementByLinkText("Upload Files").click();
driver.setLogLevel(Level.ALL);
System.out.println(driver.getCurrentUrl());
WebElement element = driver.findElement(By.xpath("//input[@name='file_1']"));
LocalFileDetector detector = new LocalFileDetector();
String path = "D://test66T.txt";
File f = detector.getLocalFile(path);
((RemoteWebElement)element).setFileDetector(detector);
element.sendKeys(f.getAbsolutePath());
driver.findElementByXPath("//html/body/div[9]/div[1]/a/span").click();

Comments

  1. Is LocalFileDector supported in the C# bindings?

    ReplyDelete
  2. thank for you information your blog isa excellent any problem sovle this movement
    once visit selenium free course online trainings

    ReplyDelete
  3. Selenium training in Chennai
    We provide best selenium training in Chennai with real time scenarios.For real time training reach us 8122241286 and become experts in selenium.
    selenium training in chennai

    ReplyDelete
  4. Thanks for sharing this information and keep updating us. This is informatics and really useful to me.
    Selenium Training in Chennai | Selenium Training | Selenium Course in Chennai

    ReplyDelete
  5. I have enjoyed the learning lesion and I regret to have missed the previous lesson. I will, therefore, bookmark this site so that I can take part in the upcoming lessons. Thanks so much for sharing with us educative and informative articles and other learning materials and information can be obtained by clicking on PhD Thesis Help.

    ReplyDelete
  6. Is there a solution for c# as well?

    ReplyDelete
  7. Awesome post. Really thanks for sharing such a valuable information. Keep updating like this ��. I t was very useful for me.
    Best Selenium Training Institute In Hyderabad | Online Selenium Training

    ReplyDelete

Post a Comment

Popular Posts