comment_list.inc': $pre .= $default_pre .= 'comment_list.inc.htm'; break; case 'message': $pre .= $default_pre .= 'message.htm'; break; case 'tag_list': $pre .= $default_pre .= 'tag_list.htm'; break; case 'tag': $pre .= $default_pre .= 'tag.htm'; break; case 'flag': $pre .= $default_pre .= 'flag.htm'; break; case 'my': $pre .= $default_pre .= 'my.htm'; break; case 'my_password': $pre .= $default_pre .= 'my_password.htm'; break; case 'my_bind': $pre .= $default_pre .= 'my_bind.htm'; break; case 'my_avatar': $pre .= $default_pre .= 'my_avatar.htm'; break; case 'home_article': $pre .= $default_pre .= 'home_article.htm'; break; case 'home_comment': $pre .= $default_pre .= 'home_comment.htm'; break; case 'user': $pre .= $default_pre .= 'user.htm'; break; case 'user_login': $pre .= $default_pre .= 'user_login.htm'; break; case 'user_create': $pre .= $default_pre .= 'user_create.htm'; break; case 'user_resetpw': $pre .= $default_pre .= 'user_resetpw.htm'; break; case 'user_resetpw_complete': $pre .= $default_pre .= 'user_resetpw_complete.htm'; break; case 'user_comment': $pre .= $default_pre .= 'user_comment.htm'; break; case 'single_page': $pre .= $default_pre .= 'single_page.htm'; break; case 'search': $pre .= $default_pre .= 'search.htm'; break; case 'operate_sticky': $pre .= $default_pre .= 'operate_sticky.htm'; break; case 'operate_close': $pre .= $default_pre .= 'operate_close.htm'; break; case 'operate_delete': $pre .= $default_pre .= 'operate_delete.htm'; break; case 'operate_move': $pre .= $default_pre .= 'operate_move.htm'; break; case '404': $pre .= $default_pre .= '404.htm'; break; case 'read_404': $pre .= $default_pre .= 'read_404.htm'; break; case 'list_404': $pre .= $default_pre .= 'list_404.htm'; break; default: $pre .= $default_pre .= theme_mode_pre(); break; } if ($config['theme']) { $conffile = APP_PATH . 'view/template/' . $config['theme'] . '/conf.json'; $json = is_file($conffile) ? xn_json_decode(file_get_contents($conffile)) : array(); } !empty($json['installed']) and $path_file = APP_PATH . 'view/template/' . $config['theme'] . '/htm/' . ($id ? $id . '_' : '') . $pre; (empty($path_file) || !is_file($path_file)) and $path_file = APP_PATH . 'view/template/' . $config['theme'] . '/htm/' . $pre; if (!empty($config['theme_child']) && is_array($config['theme_child'])) { foreach ($config['theme_child'] as $theme) { if (empty($theme) || is_array($theme)) continue; $path_file = APP_PATH . 'view/template/' . $theme . '/htm/' . ($id ? $id . '_' : '') . $pre; !is_file($path_file) and $path_file = APP_PATH . 'view/template/' . $theme . '/htm/' . $pre; } } !is_file($path_file) and $path_file = APP_PATH . ($dir ? 'plugin/' . $dir . '/view/htm/' : 'view/htm/') . $default_pre; return $path_file; } function theme_mode_pre($type = 0) { global $config; $mode = $config['setting']['website_mode']; $pre = ''; if (1 == $mode) { $pre .= 2 == $type ? 'portal_category.htm' : 'portal.htm'; } elseif (2 == $mode) { $pre .= 2 == $type ? 'flat_category.htm' : 'flat.htm'; } else { $pre .= 2 == $type ? 'index_category.htm' : 'index.htm'; } return $pre; } ?>javascript - Testcafe can see button but not click on it - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Testcafe can see button but not click on it - Stack Overflow

programmeradmin1浏览0评论

In a testcafe test how can I click on an element that is clearly clickable (with t.debug() I'm able to click on the element) and visible without using ClientFunction, or t.eval -- these "workarounds" remended in testcafe's github issues do not work.

Some additional considerations:

  • the code I'm testing is Angular 1.7.
  • the Selector is verified as correct (and I tried various types of selectors)
  • testcafe version 1.8.4
  • I've tried various t.wait times before and after selection and click
  • I've tried changing the element type (<button> to <div>, etc)

In a testcafe test how can I click on an element that is clearly clickable (with t.debug() I'm able to click on the element) and visible without using ClientFunction, or t.eval -- these "workarounds" remended in testcafe's github issues do not work.

Some additional considerations:

  • the code I'm testing is Angular 1.7.
  • the Selector is verified as correct (and I tried various types of selectors)
  • testcafe version 1.8.4
  • I've tried various t.wait times before and after selection and click
  • I've tried changing the element type (<button> to <div>, etc)
Share Improve this question edited Apr 28, 2020 at 11:18 Mate Mrše 8,46413 gold badges50 silver badges92 bronze badges asked Apr 17, 2020 at 15:01 sjt003sjt003 2,6175 gold badges25 silver badges41 bronze badges 5
  • I've also downgraded to 1.7.0 (some gh issues have suggested selector problems started in 1.7.1), but this did not help. – sjt003 Commented Apr 20, 2020 at 22:34
  • Could you please provide us an url of your page and your test code to check it? Or maybe could you create a simple example that reproduces the problem? – vrintle Commented Apr 22, 2020 at 2:17
  • no. I'm not posting my code which is proprietary. There are plenty of testcafe issues from 1.7.1 to 1.8.2 that deal with selectors and clicking. – sjt003 Commented Apr 22, 2020 at 19:10
  • any angular 1.7 buttons will suffice: both form submit buttons and buttons with an ng-click action attached – sjt003 Commented Apr 22, 2020 at 19:11
  • 2 Since you can't post your code, can you post an example? i.e. what the element looks like, and the testcafe actions you've tried. It'll help provide a more prehensive picture, since we can't see the actual code – Rob C Commented Apr 23, 2020 at 17:25
Add a ment  | 

2 Answers 2

Reset to default 5

Try waiting for the element to be visible before clicking

await element.with({ visibilityCheck: true }).with({timeout: 10000});

Here are some typical problems with unclickable elements, I know the link is for Selenium issues, but some solutions can be used regardless of the technology used.

If you already tried with various waiting to be visible/clickable solutions, the next thing that you might want to check is if you have multiple elements with the same id, one of them being invisible, so TestCafe is unable to uniquely identify the right element. In that case, you will need to improve the locator.

Another thing to consider is that the element might be out of the viewport (when not debugging). In that case, try changing the window size (or maximizing it) or moving to element.

发布评论

评论列表(0)

  1. 暂无评论