本文介绍了量角器 browser.actions().mouseMove() 不显示悬停效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是量角器的新手,并尝试为默认关闭的滑块面板添加​​测试,将鼠标悬停在上面将打开它,然后滑块面板上有一个项目列表可供选择.

I am new to protractor and trying to add tests for a slider panel which is closed by default and hovering mouse over will open it and then there are a list of items on the slider panel to pick.

<div class="slider" [ngClass]="{ closed: state === 1, open: state === 2}" (click)="onClick($event)" (mouseover)="onMouseOver($event)" (mouseleave)="onMouseLeave($event)">

我尝试了多种方法,但都不起作用.

I tried multiple ways, none of them work.

第一次尝试:(没有悬停效果,即什么都不做)

First attempt:(no hover effect, ie, do nothing)

browser.actions().mouseMove(element(by.css('.slider.closed'))).perform();

第二次尝试:(得到一个错误:指定了一个无效或非法的选择器)

Second attempt:( got an error: An invalid or illegal selector was specified)

browser.actions().mouseMove(element(by.css('[(mouseover)="onMouseOver($event)"]'))).perform();

第三次尝试:(出现错误:使用定位器找不到元素)

Third attempt: (got an error: No element found using locator)

browser.actions().mouseMove(element(by.css('[mouseover="onMouseOver($event)"]'))).perform();

推荐答案

我使用了 webdriver 并使其工作.browser.executeScript('arguments[0].click()',browser.driver.findElement(By.css('.slider')));

I used webdriver and made it work. browser.executeScript('arguments[0].click()',browser.driver.findElement(By.css('.slider')));

这篇关于量角器 browser.actions().mouseMove() 不显示悬停效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 20:57