我試圖找到iframe內的元素。所以我嘗試切換到iframe。無法在量角器測試中找到iframe
在HTML中的iframe:使用
<iframe id="id_of_iframe" data-app-id="com.s-h.ph.pr" class="external-app ng-scope ng-isolate-scope" ng-if="!vm.appDisabled" ng-attr-sandbox="{{vm.iframeConfig.sandbox ? vm.iframeConfig.sandbox : ''}}" tp-onload="vm.sendCurrentRouteToIFrame()" style="border: none; border-width: 0; height: 100%; width: 100%; display: block;" sandbox="allow-forms allow-popups allow-pointer-lock allow-same-origin allow-scripts allow-top-navigation allow-modals"></iframe>
代碼:
browser.switchTo().frame('id_of_iframe');
我收到以下錯誤:
Failed: no such frame
(Session info: chrome=61.0.3163.100)
(Driver info: chromedriver=2.32.498550 (9dec58e66c31bcc53a9ce3c7226f0c1c58
10906a),platform=Windows NT 6.1.7601 SP1 x86_64)
Stack:
NoSuchFrameError: no such frame
(Session info: chrome=61.0.3163.100)
(Driver info: chromedriver=2.32.498550 (9dec58e66c31bcc53a9ce3c7226f0c1c58
10906a),platform=Windows NT 6.1.7601 SP1 x86_64)
at WebDriverError (C:\Users\z002ex9t\AppData\Roaming\npm\node_modules\pr
otractor\node_modules\selenium-webdriver\lib\error.js:27:5)
at NoSuchFrameError (C:\Users\z002ex9t\AppData\Roaming\npm\node_modules\
protractor\node_modules\selenium-webdriver\lib\error.js:180:5)
at Object.checkLegacyResponse (C:\Users\z002ex9t\AppData\Roaming\npm\nod
e_modules\protractor\node_modules\selenium-webdriver\lib\error.js:505:15)
at parseHttpResponse (C:\Users\z002ex9t\AppData\Roaming\npm\node_modules
\protractor\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\Users\z002ex9t\AppData\Roaming\npm\node_modu
les\protractor\node_modules\selenium-webdriver\lib\http.js:440:13)
at process._tickCallback (internal/process/next_tick.js:109:7)
我使用以下版本: 「量角器」 :「5.1.2」, 「茉莉花」:「2.8.0」 webdriver-manager 12.0.6
任何想法如何解決這個問題?
在此先感謝。
我不明白你爲什麼要提供它僅含有該行代碼段,這應該是是可測試? – user10089632
請分享HTML和網址 – iamsankalp89
失敗:沒有這樣的框架問題說這是真的有框架 – iamsankalp89