【发布时间】:2021-03-09 13:20:18
【问题描述】:
我想自动化来自www.moneycontrol.com 网站的场景。 在主页上,有一个名为“市场行动”的部分,当我们将鼠标悬停在图表上时,我们会在其中获得一些值。像这样: Hovered Maximum Value from Graph
图表位于 iframe 内,需要始终悬停在最大值上。之后,我们需要获取悬停的值,并使用 Market Action 表头进行验证。
只需要使用 cypress 即可。我可以进入 iframe,但不确定为什么它没有在图表上单击/悬停。我的代码是这样的:
static getLatestValueByHoveringOnGraph = (): void => {
HomePage.getMarketActionIframeBody()
.find(".highcharts-series>path:first-child")
.click("topRight")
.trigger("mouseover");
};
private static getMarketActionIframeBody() {
return cy
.get("iframe[title='Indices Chart']")
.its("0.contentDocument")
.should("exist")
.its("body")
.should("not.be.undefined")
.then(cy.wrap);
}
几个小时以来我尝试了很多方法,但没有得到解决方案。希望有人能够解决这个问题。提前致谢。
【问题讨论】:
-
如果有公共 API,更简单的方法是从 API 响应中获取价格。
-
无法使用 API 作为悬停功能需要验证。
标签: iframe automation cypress ui-automation