等到 selenium excel vba 中出现特定值 [英] Wait until specific value appears in selenium excel vba

查看:17
本文介绍了等到 selenium excel vba 中出现特定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有这个 html 的元素

I have an element with this html

<span id="ContentPlaceHolder1_Label2" designtimedragdrop="1319" style="display:inline-block;color:Firebrick;font-size:Medium;font-weight:bold;width:510px;"></span>

点击页面上的保存按钮后,这部分变成了那个

and after clicking Save button on the page this part changes to that

<span id="ContentPlaceHolder1_Label2" designtimedragdrop="1319" style="display:inline-block;color:Firebrick;font-size:Medium;font-weight:bold;width:510px;">تم حفظ التعديل بنجاح</span>

你会注意到这个值 تم حفظ التعديل بنجاح ..之后我应该点击另一个按钮,但是当互联网连接速度很慢时就会出现问题.我在保存之前点击了另一个按钮我怎样才能等待值 تم حفظ التعديل بنجاح 的出现,然后在出现该文本之后 >> 移动到另一个按钮

You would notice this value تم حفظ التعديل بنجاح .. After that I should click another button but the problem appears when the internet connection is slow. I got the other button clicked before saving How can I wait for the appearance of the value تم حفظ التعديل بنجاح and then after the appearance of that text >> move to the another button

感谢您的帮助

推荐答案

我会重新编写这个,因为你会冒着无限循环的风险.使它成为一个定时循环并添加一个 DoEvents.

I would re-write this as you risk an infinite loop. Make it a timed loop and add in a DoEvents.

Dim result As String, testElement As Object, t As Date
Const MAX_WAIT_SEC As Long = 10 '<==adjust time here
t = Timer
Do
    DoEvents
    On Error Resume Next
    Set testElement = .FindElementById("ContentPlaceHolder1_Label2")
    result = testElement.Text
    If Timer - t > MAX_WAIT_SEC Then Exit Do
    On Error GoTo 0
Loop While result <> "تم حفظ التعديل بنجاح"

这篇关于等到 selenium excel vba 中出现特定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆