[英]Cypress: How can I get the timestamp of when Cypress start to record in headless mode?
[英]Cypress error when testing nested iframes in headless mode - race condition
我正在測試一個 Web 應用程序,並且測試在有頭模式 ( cypress open
) 下可靠地運行,但在無頭模式 ( cypress run
) 下有錯誤,所以這可能是我無法解決的競爭條件。 錯誤信息是:
[36819:0223/163815.745047:ERROR:system_services.cc(34)] SetApplicationIsDaemon: Error Domain=NSOSStatusErrorDomain Code=-50 "paramErr: error in user parameter list" (-50)
當賽普拉斯創建事件視頻時,再次提到了這個錯誤:
- Started processing: Compressing to 32 CRF
2022-02-23 17:00:19.700 Cypress Helper[37571:416134] In -[NSApplication(NSQuietSafeQuit) _updateCanQuitQuietlyAndSafely], _LSSetApplicationInformationItem(NSCanQuitQuietlyAndSafely) returned error -50
- Finished processing: /Users/malte.wirz/Documents/iframes-cypress-issue/cypress/videos/iframe-github.js.mp4 (3 seconds)
我在這里創建了一個演示存儲庫。 要復制,克隆它,運行yarn
安裝,然后yarn cypress:run
。 測試確實通過了,但出現了上述錯誤。
我假設錯誤源於訪問嵌套的 iframe,到目前為止我測試了 5 種不同的方法,但無濟於事。 我特別確保函數getIframeBody
等到每個 iframe 和請求的元素准備好。 該錯誤還會創建一個視頻,但您只能看到成功運行,錯誤消息在那里不可見。
非常感謝任何有關如何進一步調試的幫助。
describe('Testing Iframe within Iframes', () => {
it('Visits the iframe website and accesses the iframe within the iframe', () => {
const getIframeBody = (iframeSelector, elementSelectorInIframe) => {
return cy
.get(iframeSelector)
.its('0.contentDocument.body', {timeout: 30000})
.should((body) => {
expect(Cypress.$(body).has(elementSelectorInIframe).length).gt(0)
})
.then(cy.wrap)
}
// Visiting the page index.html and getting iframe A
cy.visit('index.html').contains('XHR in iframe')
getIframeBody('iframe[data-cy="bankid"]', 'iframe[src="https://tools.bankid.no/bankid-test/auth"]').as('iframeA')
cy.get('@iframeA').within(() => {
getIframeBody('iframe[src="https://tools.bankid.no/bankid-test/auth"]', 'iframe[src^="https://csfe.bankid.no/CentralServerFEJS"]').as('iframeB')
cy.get('@iframeB').within(() => {
getIframeBody('iframe[src^="https://csfe.bankid.no/CentralServerFEJS"]', 'input[type="tel"]').as('iframeC')
// Now we are in the right place and it finds the correct input element.
// However, normal cypress command .type() fails and we have to use library cypress-real-events,
// which provides an event firing system that works literally like in puppeteer
cy.get('@iframeC').find('input[type="tel"]').should('be.visible').realType('12345678912')
// But for the button below, this library now doesn't help anymore:
// "Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'."
// This was solved by using {scrollBehavior:false}.
cy.get('@iframeC').find('button[type="submit"]').should('be.visible').first().realClick({scrollBehavior:false})
})
})
})
})
我收到一些反饋,上面的“錯誤:system_services.cc(34)”並不重要,不會導致測試不穩定或不成功,因此沒有行動點。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.