【问题标题】:Dusk + Stripe = unable to locate elementDusk + Stripe = 无法定位元素
【发布时间】:2019-05-14 19:18:55
【问题描述】:

我在一个窗口中打开一个支付表单,每次 Dusk 都在努力寻找屏幕上的输入元素。我尝试添加 pause(3),但没有任何效果。

我正在运行 laravel 5.5 和 Dusk 2.0。

        $browser->waitFor('.stripe-card iframe', 30);

        // Lets make the switch to iframe
        $browser->driver
            ->switchTo()
            ->frame('__privateStripeFrame5');

        $browser->type('cardnumber', '4242424242424242')
            ->type('exp-date', '12 50')
            ->type('cvc', '123');

我试过了:

  1. type('cardnumber') 之前使用->pause(3000) 但什么也没做
  2. 使用->keys('input[name=cardnumber]', '4242424242424242') 但什么也没做

我得到的错误 Facebook\WebDriver\Exception\NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"body textar ea[name='cardnumber']"}

当使用keys() 时,我得到:Facebook\WebDriver\Exception\NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"body input[name=cardnumber]"}

【问题讨论】:

  • 错误信息是什么?
  • Facebook\WebDriver\Exception\NoSuchElementException:没有这样的元素:无法找到元素:{"method":"css selector","selector":"body textar ea[name='cardnumber'] "}
  • tests/Browser/screenshots 中的截图显示了什么?
  • 我没有在屏幕截图中看到 iframe
  • 我添加了->pause(3000) - iframe 出现了,仍然是同样的问题

标签: laravel laravel-dusk


【解决方案1】:

我会建议所有处于类似位置的人将 Laravel 升级到 5.7,将 Dusk 升级到 5.0。

Dusk 有一个名为 withinFrame() 的新方法,它使测试更易于编写和阅读:

https://github.com/laravel/dusk/commit/8bfb9f01ae09d1d9ca3ce53e36b1f020c0f8dc8f

【讨论】:

    猜你喜欢
    • 2018-07-12
    • 2012-01-11
    • 2020-11-27
    • 2021-04-22
    • 2020-12-24
    • 2022-01-06
    相关资源
    最近更新 更多