2015-11-29 62 views
1

我試圖找到一種方法來上傳使用Selenium圖片 - Python的2.7.10。無法上傳文件(閃存)

我在這裏的幾點建議找到,但沒有一次成功。

於是就有了網頁上的「上傳圖片」按鈕。當我點擊這個按鈕(在Chrome),它不顯示普通的上下文菜單(檢查元素等),但Global settingsAbout Flash player,所以我想它有什麼用flash做。

我試圖找到一個上傳標籤idsend keys存在,但它並沒有工作:

self.driver.find_element_by_id('SWFUpload_0').send_keys('screen.png') 

我在外殼安裝包裝的代碼,它可以幫助解決這個問題。

<div class="swfupload-wrapper"> 
    <object id="SWFUpload_0" type="application/x-shockwave-flash" data="/sites/all/libraries/swfupload/swfupload.swf?preventswfcaching=1448803178493" width="185" height="15" class="swfupload"><param name="wmode" value="transparent"><param name="movie" value="/sites/all/libraries/swfupload/swfupload.swf?preventswfcaching=1448803178493"><param name="quality" value="high"><param name="menu" value="false"><param name="allowScriptAccess" value="always"><param name="flashvars" value="movieName=SWFUpload_0&amp;uploadURL=%2Fswfupload&amp;useQueryString=false&amp;requeueOnError=false&amp;httpSuccess=&amp;assumeSuccessTimeout=0&amp;params=sid%3D38372a6537633265663131316238386535363966326461366632653538616538363535%26amp%3Bfile_path%3Dfiles%252Fcars%26amp%3Bop%3Dmove_uploaded_file%26amp%3Binstance%3D%257B%2522name%2522%253A%2522field_part_pictures%2522%257D%26amp%3Bwidget%3D%257B%2522file_extensions%2522%253A%2522jpg%2520jpeg%2520png%2520gif%2522%252C%2522file_path%2522%253A%2522cars%2522%252C%2522max_filesize_per_file%2522%253A%2522%2522%252C%2522max_filesize_per_node%2522%253A%2522%2522%252C%2522file_widgets%2522%253Anull%252C%2522max_resolution%2522%253A%25220%2522%252C%2522min_resolution%2522%253A%25220%2522%252C%2522alt%2522%253A%2522%2522%252C%2522custom_alt%2522%253A0%252C%2522title%2522%253A%2522%2522%252C%2522custom_title%2522%253A0%252C%2522progress_indicator%2522%253A%2522bar%2522%252C%2522title_type%2522%253A%2522textfield%2522%252C%2522use_default_image%2522%253A0%252C%2522label%2522%253A%2522Pictures%2522%252C%2522weight%2522%253A%2522-1%2522%252C%2522description%2522%253A%2522%2522%252C%2522type%2522%253A%2522swfupload_widget%2522%252C%2522module%2522%253A%2522swfupload%2522%252C%2522list_field%2522%253A%25220%2522%252C%2522list_default%2522%253A1%252C%2522description_field%2522%253A%25220%2522%257D&amp;filePostName=field_part_pictures&amp;fileTypes=*.jpg%3B*.jpeg%3B*.png%3B*.gif&amp;fileTypesDescription=&amp;fileSizeLimit=0&amp;fileUploadLimit=0&amp;fileQueueLimit=0&amp;debugEnabled=false&amp;buttonImageURL=%2Fnode%2F4182%2F&amp;buttonWidth=185&amp;buttonHeight=15&amp;buttonText=&amp;buttonTextTopPadding=0&amp;buttonTextLeftPadding=0&amp;buttonTextStyle=color%3A%20%23000000%3B%20font-size%3A%2016pt%3B&amp;buttonAction=-110&amp;buttonDisabled=false&amp;buttonCursor=-2"></object> 
    </div> 

你有什麼建議?

回答

2

據我所知,硒並沒有配備閃光燈的工作。 所以你需要使用一些其他的附加工具。

1

您可以使用sikuli與硒的文件上傳Flash對象。