这是我尝试过的以下脚本,此脚本已通过,但文件未上传:
import unittest
from selenium import webdriver
import time
import os
from selenium.webdriver.common.keys import Keys
from selenium .webdriver.common.action_chains import ActionChains
class notaryfileupload(unittest.TestCase):
def setUp(self):
self.driver=webdriver.Chrome()
def test_Notaryfileupload(self):
driver=self.driver
driver.get("https://mtsdev.westus.cloudapp.azure.com/#")
time.sleep(30)
username=driver.find_element_by_xpath("//*[@id='login-form-username']")
username.send_keys("vamsi@mindtechsol.com")
driver.implicitly_wait(4)
password=driver.find_element_by_xpath("//*[@id='login-form-password']")
password.send_keys("Mindtech@2017")
driver.implicitly_wait(4)
submit=driver.find_element_by_xpath("//*[@id='login-form-submit']")
submit.click()
driver.implicitly_wait(8)
driver.maximize_window()
time.sleep(5)
searchbox=driver.find_element_by_xpath("//*[@id='content']/div/div[2]/div[1]/div[1]/div/div/input")
searchbox.send_keys("BN0000023")
time.sleep(15)
click=driver.find_element_by_xpath("//*[@id='content']/div/div[2]/table/tbody/tr[1]/td[1]/span")
click.click()
time.sleep(20)
driver.refresh()
time.sleep(20)
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(6)
driver.execute_script("window.scrollBy(0, -550);")
time.sleep(6)
attachment=driver.find_element_by_xpath("//*[@id='content']/data-ng-form/div/div[2]/div[8]/div/work-area-template/div/div[2]/div[2]/table/thead/tr[2]/th/div/div/input[2]")
# driver.execute_script('arguments[0].style = ""; arguments[0].style.display = "block"; arguments[0].style.visibility = "visible";', attachment)
attachment.send_keys("C:\Users\vignesh\Desktop\New folder\comments.txt")
time.sleep(30)
def tearDown(self):
self.driver.quit()
if __name__ == '__main__':
unittest.main()
#attachment=driver.find_element_by_name("multifile-939[]")
#attachment.send_keys("C:\Users\vigne\Desktop\important pyton\dental.txt")