【问题标题】:Need help in determining the proper element identification for closing the popuop需要帮助确定关闭弹出窗口的正确元素标识
【发布时间】:2023-03-26 17:13:01
【问题描述】:

我正在尝试在“http:www.kayak.com/flights”自动查找航班信息。但是,当访问该站点时,它首先会显示一个弹出窗口以输入电子邮件地址并创建一个帐户。在页面中输入任何航班信息之前,需要关闭此弹出窗口。单击左上角的“x”图标可以关闭弹出窗口。即使我已经能够使用 firebug 基于 xpath 识别“x”元素的位置,但图标的 xpath 表达式在 Selenium IDE 中无法找到它。我的 xpath 表达式是

//div[@class='r9-dialog-closeButton r9-icon-x tighter'] 

有人可以提出我在提出 xpath 表达式时可能犯的错误,或者提出另一种识别此元素的方法,以便正确定位它吗?

【问题讨论】:

  • 只需发送“ESC”即可关闭弹出窗口

标签: jquery css selenium xpath selenium-ide


【解决方案1】:

一个问题是网站上的关闭按钮在r9-icon-xtighter 类之间有一个额外的空间:

<div class="r9-dialog-closeButton r9-icon-x  tighter"></div>
                                        HERE^

我会使用contains() 来避免这样的问题:

//div[contains(@class, "r9-dialog-closeButton")]

或者,使用 CSS 选择器

div.r9-dialog-closeButton

【讨论】:

  • 嗨,alecxe - 感谢您的回答。这招厉害了效果很好。
  • @HiteshKapur 请看看答案是否可以接受。谢谢。
猜你喜欢
  • 1970-01-01
  • 2015-01-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-15
  • 1970-01-01
相关资源
最近更新 更多