【发布时间】:2017-01-02 02:09:14
【问题描述】:
我希望有人能够帮助我解决我的问题。我在网上做了很多研究,还没有找到任何特定的解决方案。
在运行我的测试用例时,我有时会遇到无法在我的脚本中处理的 HTML 弹出窗口。它是非常随机的(完全基于客户在浏览网站时的行为),并且可以在客户旅程中的任何时候弹出。有时它根本不会弹出。只有当它出现时,才会在 DOM 中看到一个条目。
基本上,它是一个实时聊天窗口(准确地说是 LivePerson),向客户建议如果他们愿意,可以有代理帮助他们完成订单。
这是截图:
当我检查元素时,以下内容在 Firebug 中可用:
<div id="LPMcontainer-1483053256847-0" class="LPMcontainer LPMoverlay" style="margin: -143px 0px 0px -285px; padding: 0px; border-style: solid; border-width: 0px; outline-color: rgb(106, 159, 177); outline-width: 2px; font-style: normal; font-weight: normal; font-variant: normal; list-style: outside none none; letter-spacing: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: normal; word-spacing: normal; background-repeat: repeat-x; background-position: left bottom; background-color: transparent; border-color: transparent; width: 571px; height: 287px; cursor: pointer; display: block; z-index: 107158; position: fixed; top: 50%; bottom: auto; left: 50%; right: auto;">
<div role="button" tabindex="0"><img src="https://www./content/dam/tcom/apps/live-person/live-person-chat-bundles-top.jpg" id="LPMimage-1483053256849-2" alt="" class="LPMimage" style="margin: 0px; padding: 0px; border-style: none; border-width: 0px; outline-color: rgb(106, 159, 177); outline-width: 2px; font-style: normal; font-weight: normal; font-variant: normal; list-style: outside none none; letter-spacing: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: normal; word-spacing: normal; position: absolute; z-index: 600; left: 0px; top: 0px;">
</div>
<img src="https://www./content/dam/tcom/apps/live-person/live-person-chat-bottom.jpg" id="LPMcloseButton-1483053256847-1" alt="" class="LPMcloseButton" style="margin: 0px; padding: 0px; border-style: none; border-width: 0px; outline-color: rgb(106, 159, 177); outline-width: 2px; font-style: normal; font-weight: normal; font-variant: normal; list-style: outside none none; letter-spacing: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: normal; word-spacing: normal; position: absolute; cursor: pointer; z-index: 9999; left: 0px; top: 194px;" data-lp-event="close" role="button" tabindex="0">
</div>
它出现在所有浏览器中。
我想通过以下任一方式处理:
- 完全停止加载(同样由于随机性)。 或
- 在执行脚本时,一旦出现窗口,它就会按下“不,谢谢”按钮(上面代码中的 id="LPMcloseButton-1483053256847-1"),然后继续执行其余步骤。请注意,id 本质上是动态的,即每次都是唯一的。
我们将非常感谢您的帮助。
【问题讨论】:
标签: selenium