是否会在Selenium WebDriver下自动提供session_start()的会话cookie?

问题描述 投票:0回答:1

我需要做些什么来使PHPSESSID cookie可测试?

我有index.php,我用session_start ()设置cookie,这让我在“现实生活中”会话cookie“PHPSESSID”。

现在我只想看到cookie存在

$I->amOnPage('/index.php');
$I->seeCookie('PHPSESSID');

但我明白了

Fail Failed asserting that an array contains 'PHPSESSID'.

像see('something','h4')这样的简单测试工作得很好。

acceptance.suite.yml

 actor: AcceptanceTester
 modules:
     enabled:
         - WebDriver:
             url: http://nginx-web/     
             browser: chrome
             host: chrome                
             window_size: maximize
         - \Helper\Acceptance

我使用下面的图像在Docker中运行它,但这应该没有任何区别:

codeception/codeception:2.3.5 and 
selenium/standalone-chrome-debug:3.7.1

问题:我是否必须为饼干“活着”做些其他事情?我几乎认为我需要在Codeception中使用setCookie,但这似乎不合逻辑(手动创建cookie)。如果我这样做,我实际上无法测试session_start()是否有效。

任何帮助深表感谢!

selenium-webdriver codeception
1个回答
0
投票

它确实与docker setup ....等等有关。我们的nginx服务器在反向代理后运行,而且我们有检查,如果您不是来自我们的域,则不允许您执行特定操作。对于一些尚未知道的原因,这也会以某种方式干扰cookie,即使从一开始就是如此。

解决方案:在你的docker-compose中设置selenium图像extra_hosts

© www.soinside.com 2019 - 2024. All rights reserved.