无法上传文件(Flash)

时间:2015-11-29 13:26:50

标签: python python-2.7 selenium request

我试图找到一种使用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 个答案:

答案 0 :(得分:2)

据我所知,硒不适用于闪光灯。 所以你需要使用其他一些额外的工具。

答案 1 :(得分:1)

您可以使用sikuli和selenium在flash对象中上传文件。