我在网站上有一些元素
<div id="checkout">
<a href="" onclick="submitHostedPage('z_hppm_iframe'); return false;">Submit</a>
</div>
在浏览器中完全正常(可点击),或者可以通过document.querySelector("#checkout > a").click()
目标javascript方法通常提交来自第三方外部的iframe,一切似乎都没问题。
现在,当我尝试执行此点击或直接运行目标javascript方法时,我没有得到正面响应Behat(步骤已经过去)但实际上脚本未执行。应该可以看到一些验证错误,或者加载结帐表单并加载下一页。
知道如何调试吗?
当我执行Behat步骤时
Then I click on element "#checkoutSummary > a"
来自Selenium(Docker容器)的日志看起来像那样
selenium_1 | 2017-06-15 10:14:33,438 DEBG 'selenium' stderr output:
selenium_1 | 10:14:33.437 INFO - Executing: [find elements: By.xpath: //html/descendant-or-self::*[@id = 'checkoutSummary']/a])
selenium_1 |
selenium_1 | 2017-06-15 10:14:33,449 DEBG 'selenium' stderr output:
selenium_1 | 10:14:33.449 INFO - Done: [find elements: By.xpath: //html/descendant-or-self::*[@id = 'checkoutSummary']/a]
selenium_1 |
selenium_1 | 2017-06-15 10:14:33,451 DEBG 'selenium' stderr output:
selenium_1 | 10:14:33.451 INFO - Executing: [find element: By.xpath: (//html/descendant-or-self::*[@id = 'checkoutSummary']/a)[1]])
selenium_1 |
selenium_1 | 2017-06-15 10:14:33,461 DEBG 'selenium' stderr output:
selenium_1 | 10:14:33.461 INFO - Done: [find element: By.xpath: (//html/descendant-or-self::*[@id = 'checkoutSummary']/a)[1]]
selenium_1 |
selenium_1 | 2017-06-15 10:14:33,463 DEBG 'selenium' stderr output:
selenium_1 | 10:14:33.462 INFO - Executing: [mousemove: 46 false])
selenium_1 |
selenium_1 | 2017-06-15 10:14:33,491 DEBG 'selenium' stderr output:
selenium_1 | 10:14:33.490 INFO - Done: [mousemove: 46 false]
selenium_1 |
selenium_1 | 2017-06-15 10:14:33,493 DEBG 'selenium' stderr output:
selenium_1 | 10:14:33.492 INFO - Executing: [click: 46 [[FirefoxDriver: firefox on LINUX (65a37ed4-e04f-47ec-89fa-d007b2173b54)] -> xpath: //html/descendant-or-self::*[@id = 'checkoutSummary']/a]])
selenium_1 |
selenium_1 | 2017-06-15 10:14:33,554 DEBG 'selenium' stderr output:
selenium_1 | 10:14:33.554 INFO - Done: [click: 46 [[FirefoxDriver: firefox on LINUX (65a37ed4-e04f-47ec-89fa-d007b2173b54)] -> xpath: //html/descendant-or-self::*[@id = 'checkoutSummary']/a]]
selenium_1 |
selenium_1 | 2017-06-15 10:14:33,559 DEBG 'selenium' stderr output:
selenium_1 | 10:14:33.559 INFO - Executing: [set window size])
selenium_1 |
selenium_1 | 2017-06-15 10:14:33,567 DEBG 'selenium' stderr output:
selenium_1 | 10:14:33.567 INFO - Done: [set window size]
selenium_1 |
selenium_1 | 2017-06-15 10:14:33,570 DEBG 'selenium' stderr output:
selenium_1 | 10:14:33.570 INFO - Executing: [get current url])
selenium_1 |
selenium_1 | 2017-06-15 10:14:33,575 DEBG 'selenium' stderr output:
selenium_1 | 10:14:33.575 INFO - Done: [get current url]
selenium_1 |
selenium_1 | 2017-06-15 10:14:33,590 DEBG 'selenium' stderr output:
selenium_1 | 10:14:33.589 INFO - Executing: [take screenshot])
selenium_1 |
selenium_1 | 2017-06-15 10:14:33,728 DEBG 'selenium' stderr output:
selenium_1 | 10:14:33.728 INFO - Done: [take screenshot]
selenium_1 |
selenium_1 | 2017-06-15 10:14:33,845 DEBG 'selenium' stderr output:
selenium_1 | 10:14:33.845 INFO - Executing: [delete session: 5cfca9c7-e13d-472e-a5bb-4d25ac2ae6bf])
selenium_1 |
selenium_1 | 2017-06-15 10:14:33,917 DEBG 'selenium' stderr output:
selenium_1 | 10:14:33.916 INFO - Done: [delete session: 5cfca9c7-e13d-472e-a5bb-4d25ac2ae6bf]
截取屏幕截图只是确认出现问题,因为当前网址不是预期的网址。
我还尝试直接从Behat执行js,这似乎可以工作,因为我可以在Selenium日志的以下输出中看到这一点,但是没有任何javascript脚本执行/操作的结果。
selenium_1 |
selenium_1 | 2017-06-14 14:40:58,776 DEBG 'selenium' stderr output:
selenium_1 | 14:40:58.776 INFO - Executing: [execute script: return submitHostedPage('z_hppm_iframe');, []])
selenium_1 |
selenium_1 | 2017-06-14 14:40:58,786 DEBG 'selenium' stderr output:
selenium_1 | 14:40:58.785 INFO - Done: [execute script: return submitHostedPage('z_hppm_iframe');, []]
selenium_1 |
selenium_1 | 2017-06-14 14:40:58,892 DEBG 'selenium' stderr output:
selenium_1 | 14:40:58.892 INFO - Executing: [set window size])
selenium_1 |
selenium_1 | 2017-06-14 14:40:58,899 DEBG 'selenium' stderr output:
selenium_1 | 14:40:58.899 INFO - Done: [set window size]
selenium_1 |
selenium_1 | 2017-06-14 14:40:58,902 DEBG 'selenium' stderr output:
selenium_1 | 14:40:58.902 INFO - Executing: [execute script: return false;, []])
任何建议都非常感谢。