简体   繁体   English

无法找到按钮并使用单击功能:Java的Selenium WebDriver

[英]Not able to locate the button and use click function: Selenium WebDriver with Java

I am not able to locate the button and click it in the website i am automating using selenium webdriver with java. 我无法找到按钮并在使用Java的Selenium Webdriver自动运行的网站中单击它。 Could anyone Help? 有人可以帮忙吗? (using CSS selectors) (使用CSS选择器)

Below is the HTML for the button 以下是按钮的HTML

<div class="inputWrapper newButton" name="uploadDiv">
<h6 name="fileUpload">
<label for="pdfFileUplod">Upload file</label>
</h6>
<input id="pdfFileUplod" class="fileInput hidden_" type="file" onchange="checkFile = checkFileName(this);" name="uploadFile"/>
</div>

If you think on file upload button, you have id, so use it: 如果您认为文件上传按钮具有ID,请使用它:

WebElement el = driver.findElement(By.Id("pdfFileUplod"));
el.click()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM