Playwright测试在GitLab CI中打开新标签丢失URL查询参数
Playwright无头模式下新标签URL查询参数丢失问题
我用Playwright编写的测试逻辑是点击按钮在新标签页打开页面,本地VS Code有头模式运行时流程完全正常,但在GitLab CI无头模式运行时,新标签页虽能打开,URL里的查询参数却被彻底截断。测试基于Chromium,相关代码如下:
async cancelInsurance() { const popupPromise = this.page.waitForEvent('popup'); await this.page.locator(Selectors.idpLink).click(); const newTab = await popupPromise; console.log(newTab.url()); await newTab.click(Selectors.cancelButton); }
示例URL:
- GitLab CI中打开的URL:
https://test-environment.com/insurance_details.en-gb.html - 本地正常打开的URL:
https://test-environment.com/insurance_details.en-gb.html?&aid=100000&auth_key=12345
更新:开启DEBUG=pw:api后得到以下日志:
pw:api => locator.click started +1ms pw:api waiting for event "popup" +8ms pw:api checking visibility of locator(':scope') +7ms pw:api waiting for locator('[data-testid="insurance-banner-card-view-details_testid"]') +2ms pw:api locator resolved to <a target="_blank" aria-label="View insurance summary" data-testid="insurance-banner-card-view-details_testid" class="a83ed08757 c21c56c305 bf0537ecb5 ab98298258 af7297d90d" href="https://test-environment.com/insurance_details.en-gb.html">…</a> +2ms pw:api attempting click action +4ms pw:api waiting for element to be visible, enabled and stable +0ms pw:api <= elementHandle.isHidden succeeded +2ms pw:api element is visible, enabled and stable +29ms pw:api scrolling into view if needed +0ms pw:api done scrolling +1ms pw:api performing click action +7ms pw:api click action done +13ms pw:api waiting for scheduled navigations to finish +0ms pw:api navigations have finished +0ms pw:api <= locator.click succeeded +5ms pw:api "load" event fired +750ms pw:api navigated to "https://ct.pinterest.com/ct.html" +6ms pw:api "commit" event fired +496ms pw:api "commit" event fired +6ms pw:api navigated to "https://test-environment/insurance_details.en-gb.html" +1ms pw:api <= page.waitForEvent succeeded +4ms https://test-environment.com/insurance_details.en-gb.html pw:api => page.click started +2ms pw:api waiting for locator('button:has(span.e4adce92df:has-text("cancel"))') +14ms pw:api "domcontentloaded" event fired +
内容的提问来源于stack exchange,提问作者Fenomenoq
相关产品推荐
相关产品推荐

