문제

I have 2 buttons with the same name. For design reasons only one of them is visible at the same time.

I want to click on any visible button.

If first button is hided this expression

$this->byCssSelector('[name="saveAndClose"]')->click()

returns

Element is not currently visible and so may not be interacted with

How to click on visible button?

도움이 되었습니까?

해결책

I have written simple code to this.

public function clickOnDisplayedElementByName($name)
    {
    $elements = $this->elements($this->using('css selector')->value('[name="' . $name . '"]'));
    foreach ($elements as $element)
        {
        if ($element->displayed())
            {
            $element->click();
            return;
            }
        }
    $this->fail('There is no visible elements with name ' . $name);
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top