简体   繁体   English

Selenium WebDriver 和 java 找不到元素和隐式等待问题

[英]Selenium WebDriver and java Can't find element & implicit wait problems

I've been trying to write a Selenium script in Java that will fill out an 'button' field on a web site我一直在尝试用 Java 编写一个 Selenium 脚本,该脚本将填写网站上的“按钮”字段

I'm trying to find this element我试图找到这个元素

<div class="T-I J-J5-Ji T-I-KE L3 T-I-JW T-I-JO" role="button" tabindex="0" style="-moz-user-select: none;" gh="cm">REDACTAR</div>

First I go to the page, then I wait for a few seconds before I try to find the element but it doesnt works, it keeps telling me: "org.openqa.selenium.NoSuchElementException: Unable to locate element"首先,我转到页面,然后等待几秒钟,然后再尝试查找该元素但它不起作用,它一直告诉我: "org.openqa.selenium.NoSuchElementException: Unable to locate element"


this is the line这是线

driver.findElement(By.xpath(".//*[@id=':3e']/div/div")).click();

Mr.Edward, I have an answer for this question.爱德华先生,这个问题我有答案。 Implicit wait is used only for FindElement() ok?....and also Explicit wait is used only for some methods like getText() and all. Implicit等待仅用于FindElement() ok?....而且Explicit等待仅用于某些方法,如getText()等。 if we are not able find these waits() then concepts comes Annotations,This is the best way to locate the Element, Please go through some of the Annotation tutorials,then also if you find any queries pls revert me back.如果我们找不到这些waits(),那么概念就是注释,这是定位元素的最佳方法,请阅读一些注释教程,然后如果您发现任何疑问,请回复我。

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

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