如何在PHP中重用selenium会话?

如何在PHP中重用selenium会话?,php,session,selenium,Php,Session,Selenium,我在代码的函数2中重用selenium会话对象时遇到问题。我该怎么做? 调用第一个函数并显示结果。然后从HTMLPOST方法调用第二个函数。如何使用第一个函数会话在第二个函数中运行selenium? 谢谢 但未定义第二个函数中的$webdriver,它必须与第一个函数中的$webdriver具有相同的会话id 如何才能做到这一点?显示了一个Webdriver选项-browserSessionReuse 建议阅读该页面上的所有答案,这可能会有所帮助。如果您可以在单击提交按钮之前获得会话id,jQu

我在代码的函数2中重用selenium会话对象时遇到问题。我该怎么做? 调用第一个函数并显示结果。然后从HTMLPOST方法调用第二个函数。如何使用第一个函数会话在第二个函数中运行selenium? 谢谢

但未定义第二个函数中的$webdriver,它必须与第一个函数中的$webdriver具有相同的会话id 如何才能做到这一点?

显示了一个Webdriver选项-browserSessionReuse


建议阅读该页面上的所有答案,这可能会有所帮助。

如果您可以在单击提交按钮之前获得会话id,jQuery或类似工具可以在表单中添加隐藏元素,其值可以是会话ID。然后在
process.php
上检查POST var值。这可能在概念上有所帮助,即使代码语言是Javano,我也无法获取会话。而且我确信它不起作用,selenium会话是具有资源id的对象。无法使用隐藏值发送此邮件。请在此处查看已接受的答案:
$webdriver = new WebDriver("localhost", "4444");
$webdriver->connect("firefox");
$webdriver->get("http://AAA.AAA");
//here with some method i store picture of captcha to show 
echo '<form  method="post" action="process.php">
<table class="table">
    <tr>
        <td>Enter value of picture
            <img src="thumb.jpeg">
        </td>
        <td>
            <input type="text" name="captcha" dir="ltr">
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <button class="submit">Send</button>
        </td>
    </tr>
</table>
</form>';
$webdriver->findElementBy("id","username")->sendKeys("XXX");
$webdriver->findElementBy("id","password")->sendKeys("YYYY");
$webdriver->findElementBy("id","captcha")->sendKeys($_POST['captcha']);    
$webdriver->findElementBy("id","submit")->click();