求指导用selenium怎么上传图片,用.sendKeys(filename)的方法无效
<!DOCTYPE html><html>
<head> … </head>
<body style="padding-right: 17px; overflow: hidden;">
<div id="content"> … </div>
<script src="/omp-web/resources/js/jquery.min.js"></script>
<script type="text/javascript"> … </script>
<script src="http://static.geetest.com/static/tools/gt.js"></script>
<script src="/omp-web/resources/js/verifycode.js"></script>
<script src="/omp-web/resources/js/common.js"></script>
<script src="/omp-web/resources/js/qrcode.js"></script>
<script src="/omp-web/resources/js/highcharts.js"></script>
<script src="/omp-web/resources/bundle/index/common.js"></script>
<script src="/omp-web/resources/bundle/index/index.js"></script>
<div class="verifyPop"> … </div>
<div>
<div data-reactroot="">
<div class="ant-modal-mask"></div>
<div class="ant-modal-wrap " tabindex="-1" role="dialog" aria-labelledby="rcDialogTitle0" style="">
<div class="ant-modal form-modal" role="document" style="width: 640px; transform-origin: 765px 73px 0px;">
<div class="ant-modal-content">
<button class="ant-modal-close" aria-label="Close"> … </button>
<div class="ant-modal-header"> … </div>
<div class="ant-modal-body">
<form class="ant-form-horizontal common-component-form">
<div class="common-component-form-item-title"> … </div>
<div class="ant-form-item ant-form-item-with-help"> … </div>
<div class="ant-form-item ant-form-item-with-help">
<label class="ant-col-4" for="fengmian"> … </label>
<div class="ant-col-18">
<div class="ant-form-item-control ">
<span class="">
<div class="ant-upload-list ant-upload-list-picture-card"> … </div>
<div class="ant-upload ant-upload-select ant-upload-select-picture-card">
<span class="rc-upload" role="button" tabindex="0">
<input type="file" accept="" style="display: none;"></input>
<i class=" anticon anticon-plus"></i>
<div class="ant-upload-text">
选择课程封面
</div>
</span>
</div>
</span>
用xpath定位到了新增图片的元素driver.findElement(By.xpath("//div/div/div/div/div/div/form/div/div/div/span/div/span/i"));在方法后面加上.sendKeys("C:\\Users\\Administrator\\Desktop\\baidu.jpg");没看到有上传图片的动作,程序也没报错,求大神指导 求大神指导,网上看到说要利用AutoIT工具来实现 报的错误是Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 30.01 seconds t2107080 发表于 2016-12-3 11:04
报的错误是
上传的界面截个图,来看看~
页:
[1]