Javascript PHPUnit+Selenium:“displated()”在popover元素上不起作用

Javascript PHPUnit+Selenium:“displated()”在popover元素上不起作用,javascript,php,selenium,selenium-webdriver,phpunit,Javascript,Php,Selenium,Selenium Webdriver,Phpunit,在我的PHPUnit_Extensions_Selenium2TestCase测试用例中,我尝试打开一个bootstrap popover元素,然后单击其中的链接 我设法打开了它,但是我不能点击链接,因为PHPUnit认为它仍然是隐藏的。我使用WaitTill函数,但是它超时了,尽管元素实际上是可见的,但我可以在运行测试用例时看到打开的popover 我的代码: // open popover $this->byXPath("//something")->click(); // w

在我的PHPUnit_Extensions_Selenium2TestCase测试用例中,我尝试打开一个bootstrap popover元素,然后单击其中的链接

我设法打开了它,但是我不能点击链接,因为PHPUnit认为它仍然是隐藏的。我使用WaitTill函数,但是它超时了,尽管元素实际上是可见的,但我可以在运行测试用例时看到打开的popover

我的代码:

// open popover
$this->byXPath("//something")->click();

// wait
$this->waitUntil(function() {
    return $this->byId("myId")->displayed() ? true : null;
}, 2000);

// click on link (never reached, the previous function timeouts)
$this->byId("myId")->click();

谢谢你的帮助。

我不确定你为什么会出错,我相信问题出在你的标记/js上。刚刚使用最新的库检查了以下内容,由于某些原因,url导航无法从popover运行:

class Test extends PHPUnit_Extensions_Selenium2TestCase
{

    protected function setUp()
    {
        $this->setBrowser('chrome');
        $this->setBrowserUrl('');
    }

    public function test()
    {
        $this->url('http://jsfiddle.net/ianbytchek/0adyuhkg/embedded/result/');
        $this->frame($this->byXPath('//*[@id="result"]/iframe'));

        // open popover
        $this->byXPath("//button")->click();

        // wait
        $this->waitUntil(function () {
            return $this->byId("myId")->displayed();
        }, 2000);

        // click on link (never reached, the previous function timeouts)
        $this->byId("myId")->click();

        sleep(10);
    }
} 

当点击链接时,按钮会改变样式,检查。

弹出窗口可能是一个吗?不,它只是一个。你是对的,问题不在这里:我使用隐藏来存储popover内容,并将其html提供给popover函数:content:function{return$this.find'.hiddendiv'.html;}。当然,我的XPath找到了隐藏分区中的id。已解决,谢谢。