Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
389 views
in Technique[技术] by (71.8m points)

selenium - Robot Framework / Selenium中的“可见”和“点击元素”之间有区别吗?(Is there a difference between “is visible” and “click element” in Robot Framework/Selenium?)

These two lines don't work as expected:

(这两行无法正常工作:)

wait until element is visible  ${my xpath}
SeleniumLibrary.click element  ${my xpath}

Approximately half of the time the second line fails.

(第二行出现故障的时间大约是一半。)

I am not in front of my computer now but it either fails with stale element or couldn't find element with id... .

(我现在不在电脑前,但是它要么由于过时的元素而失败,要么找不到ID ...的元素 。)

If I add a sleep 3 or so inbetween the lines the second line never fails.

(如果我在两行之间添加sleep 3左右,则第二行永远不会失败。)

These two lines work frequently but they also fail frequently.

(这两条线经常工作,但也经常失败。)

Is there a difference in how RF detects that something is visible and how Selenium sends a click to the same element?

(RF如何检测可见的东西以及Selenium如何将点击发送到同一元素有什么区别?)

  ask by EmLi translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can include a custom timeout in the first keyword instead of using sleep.

(您可以在第一个关键字中包含自定义超时,而不使用睡眠。)

Wait Until Element Is Visible  ${my xpath}  3 seconds
Click Element                  ${my xpath}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...