首页 > 解决方案 > 单击锚标记不会导航到目标目的地

问题描述

问题:使用 Chrome 的设备模拟器单击移动设备中的某些锚元素无法导航到目标链接。

在这里,我试图通过单击一个图标来测试将产品单元格的样式从网格视图切换到列表视图的行为,该图标是一个带有包含参数“disp = list”的href的锚标记。

现在单击该图标没有任何作用,在导航栏中其他锚元素上执行的单击操作中可以看到相同的行为。当我在我的 chrome 模拟器和 saucelabs 中手动测试时,一切都按预期工作,但当我尝试使用 testcafe 时失败,因为它使用我本地安装的浏览器,所以它不应该有任何区别。

测试页面

命令: testcafe "chrome:emulation:device=iphone X" path-to-file.js

浏览器/操作系统:Chrome 75.0.3770 / Mac OS X 10.14.5

测试失败的 GIF

这是测试:

fixture`[mobile] navigation`
  .page('https://tw.bid.yahoo.com/search/auction/product?qt=product&kw=iphone&p=iphone')

test
  ('Clicking the view button should switch item cell view', async t => {
    await t
       .click(Selector('.ViewSwitchButton__viewButton___1r1Kh.MobileNavigation__menuButton___1OVvQ'))
        .expect(getPageUrl()).contains('disp=list')
  })

单击视图样式图标应将页面从网格视图更新为列表视图,并将 URL 更新为https://tw.bid.yahoo.com/search/auction/product?disp=list&kw=iphone&p=iphone&refine=-prop_3%2C-prop_2

预期视图

标签: testingautomated-testse2e-testingtestcafeweb-testing

解决方案


我已经在“testcafe-hammerhead”代理下重现了这种行为。这是您可以跟踪的问题:https://github.com/DevExpress/testcafe-hammerhead/issues/2080。

该修复程序包含在 TestCafe v1.6.0中。


推荐阅读