Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java selenium读取Java脚本弹出值_Java_Selenium - Fatal编程技术网

Java selenium读取Java脚本弹出值

Java selenium读取Java脚本弹出值,java,selenium,Java,Selenium,请查看此页面:https://bitly.com/2wokiu4+ 当鼠标位于蓝色图表上方时,我想阅读一些文本,并将其与页面上的另一个值进行比较(单击) 你知道我如何读取这个值吗 我尝试在HTML上搜索,下面的代码获取高度不为0的所有图表,每个图表的点击次数,汇总所有点击次数,并与右上角的点击量进行比较 WebDriverWait wait = new WebDriverWait(driver, 20); Actions actions = new Actions(driver); int c

请查看此页面:
https://bitly.com/2wokiu4+

鼠标位于蓝色图表上方时,我想阅读一些文本,并将其与
页面上的另一个值进行比较(
单击

你知道我如何读取这个
值吗


我尝试在
HTML

上搜索,下面的代码获取高度不为0的所有图表,每个图表的点击次数,汇总所有点击次数,并与右上角的点击量进行比较

WebDriverWait wait = new WebDriverWait(driver, 20);
Actions actions = new Actions(driver);

int clicks = Integer.valueOf(wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("info-wrapper--clicks-text"))).getText());

List<WebElement> charts = wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector(".highcharts-series-group rect:not([height='0'])")));

AtomicInteger totalChartClicks = new AtomicInteger();

charts.forEach(webElement -> {
    actions.moveToElement(webElement).perform();
    int amount = Integer.valueOf(driver.findElement(By.cssSelector("div.highcharts-tooltip span:nth-of-type(2)")).getText().replace("Total Clicks ",""));
    totalChartClicks.addAndGet(amount);
});

Assert.assertEquals(totalChartClicks.get(), clicks);
WebDriverWait wait=newwebdriverwait(驱动程序,20);
动作动作=新动作(驱动);
int clicks=Integer.valueOf(wait.until(ExpectedConditions.visibilityOfElementLocated(By.className(“信息包装器--单击文本”))).getText());
列表图表=wait.until(由.cssSelector(“.highcharts系列组rect:not([height='0']))指定的所有元素的预期条件.可见性);
AtomicInteger totalChartClicks=新的AtomicInteger();
charts.forEach(webElement->{
actions.moveToElement(webElement.perform();
int amount=Integer.valueOf(driver.findelelement(By.cssSelector(“div.highcharts-tooltip span:n类型(2)”)).getText().replace(“总点击次数”);
totalChartClicks.addAndGet(金额);
});
Assert.assertEquals(totalChartClicks.get(),clicks);

请您解释一下图表。forEach?您可以找到解释