离子框架模态点击量角器测试无效

时间:2021-03-11 19:40:23

I am building an app with Ionicframework in which I have a modal with a list of directives. I am now writing some protractor E2E tests and all was going well until I had to click on one of the directives.

我正在用Ionicframework构建一个应用程序,在这个应用程序中,我有一个带有一系列指令的模态。我现在正在编写一些pro拖拉机E2E测试,一切都进行得很顺利,直到我不得不单击其中一个指令。

The error I get is:

我得到的错误是:

UnknownError: unknown error: Element is not clickable at point (185, 212). Other element would receive the click: <div class="modal-backdrop active">...</div>

未知错误:元素在点(185,212)不能点击。其他元素将接收点击:

This could have something to do with the animation of the modal sliding in, so I found this 'solution':

这可能与模态滑动的动画有关,所以我找到了这个“解决方案”:

it 'is very annoying', ->
  members = element.all(By.css('member')) # The directives are: <member >
  EC = protractor.ExpectedConditions

  if members.first()
    browser.wait(EC.elementToBeClickable(members.first()), 5000).then ->
      element.all(By.css('member')).each (member) ->
        member.click()

I still get the error however.

但是我还是得到了错误。

'Tricks' like browser.sleep(2000) have also not worked so far.

《睡眠》(sleep)(2000)一书迄今为止也没有奏效。

Does anyone know how I can get it to work?

有人知道我怎么让它工作吗?

1 个解决方案

#1


3  

As always when asking a question like this you are forced to cut down everything to the basics and start thinking out of the box (at least your own box).

像往常一样,当你问这样的问题时,你不得不把所有的事情都简化到最基本的程度,并开始跳出固有的思维模式(至少是你自己的思维模式)。

The solution:

解决方案:

element(By.cssContainingText('member .member-name', "Mark Twain")).click()

This is because Angular pops-out a div from the directive and binds all events on this. .member-name is a p inside of the member and clicking that apparently does the trick.

这是因为角弹出指令中的div并绑定上面的所有事件。member-name是成员内部的一个p,单击它显然可以达到目的。

:)

:)

#1


3  

As always when asking a question like this you are forced to cut down everything to the basics and start thinking out of the box (at least your own box).

像往常一样,当你问这样的问题时,你不得不把所有的事情都简化到最基本的程度,并开始跳出固有的思维模式(至少是你自己的思维模式)。

The solution:

解决方案:

element(By.cssContainingText('member .member-name', "Mark Twain")).click()

This is because Angular pops-out a div from the directive and binds all events on this. .member-name is a p inside of the member and clicking that apparently does the trick.

这是因为角弹出指令中的div并绑定上面的所有事件。member-name是成员内部的一个p,单击它显然可以达到目的。

:)

:)