Selenium File Upload java Script

Source: Internet
Author: User

When writing the file upload script, encountered a lot of problems, including element positioning, as well as upload operations, now summarizes the following points:

1. Upload the control positioning to be accurate, when necessary to wait

Webelement adfileupload = driver.findelement (By.xpath ("//input[@type = ' file ']");

2. Upload operation

String FilePath = "d:\\taxonomy\\db\\haiertaxonomy.xlsx";    Adfileupload.sendkeys (FilePath);     try {thread.sleep (10000);     } catch (Interruptedexception e) {e.printstacktrace ();    } driver.findelement (By.xpath ("//button[@class = ' btn btn-primary start '] [@type = ' button ']"). Click ();    Driver.manage (). Timeouts (). implicitlywait (Timeunit.seconds); Driver.findelement (By.xpath ("//input[@id = ' Complete-template-upload ' [@type = ' button ']"). Click ();

3. As the script above, the path of the file must be accurate, or even if the script is not error, the file still upload failed.

Selenium File Upload java Script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.