Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String script = "document.getElementById('fileName').value='" + "C:\\temp\\file.txt" + "';";
- ((IJavaScriptExecutor)driver).ExecuteScript(script);
- driver.find_element(:id, 'upload').send_keys('/foo/bar')
- # presumes webdriver has loaded the web page of interest
- element_input = webdriver.find_element_by_css_selector('input[id="uploadfile"]')
- handle_dialog(element_input, "foobar.txt")
- def handle_dialog(element_initiating_dialog, dialog_text_input):
- def _handle_dialog(_element_initiating_dialog):
- _element_initiating_dialog.click() # thread hangs here until upload dialog closes
- t = threading.Thread(target=_handle_dialog, args=[element_initiating_dialog] )
- t.start()
- time.sleep(1) # poor thread synchronization, but good enough
- upload_dialog = webdriver.switch_to_active_element()
- upload_dialog.send_keys(dialog_text_input)
- upload_dialog.send_keys(selenium.webdriver.common.keys.Keys.ENTER) # the ENTER key closes the upload dialog, other thread exits
- string filePath = @"drive:pathfilename.filextension";
- driver.FindElement(By.Id("fileInput")).SendKeys(filePath);
- string filePath = "drive:/path/filename.filextension";
- driver.FindElement(By.Id("fileInput")).SendKeys(filePath);
- @driver.find_element(:xpath, "html/body/div[1]/div[2]/div[1]/form/div[4]/div[7]/table/tbody/tr[1]/td[2]/input").send_keys "C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg"
Add Comment
Please, Sign In to add comment