Может кто то сталкивался с проблемой такой? Инструменты Behat, php, selenium server.
Вот есть решение но как его написать на Behat php
from selenium import webdriver
d = webdriver.Firefox()
d.get("http://drupal.fckeditor.net/demo4")
d.switch_to_frame("FCKeditor1___Frame")
d.find_element_by_css_selector(".TB_Button_Text").click()
d.find_element_by_css_selector(".SourceField").send_keys("text")
Похоже никто не работает с Behat
В общем решил проблему.
Первым шагом назначаем id вашему iframe. (Потому как у моего iframe не было id)
public function theIframeInElementHasId($element_id, $iframe_id)
{
$function = <<<JSS
(function(){
var elem = document.getElementById("$element_id");
var iframes = elem.getElementsByTagName('iframe');
var f = iframes[0];
f.id = "$iframe_id";
})()
JSS;
try {
$this->getSession()->executeScript($function);
} catch (Exception $e) {
throw new \Exception(sprintf('No iframe found in the element "%s" on the page "%s".', $element_id, $this->getSession()->getCurrentUrl()));
}
}
Первый параметр $element_id - это ближайшей элемент. параметр $iframe_id - это присвоение вашему iframe идишник.
- Второй шаг это переключение в этот iframe.
public function iSwitchToIframe($id)
{
$this->getSession()->wait(5000);
$this->getSession()->switchToIFrame($id);
}
- Последний шаг это заполнение вашего iframe. Пишите какой-либо локатор в iframe и там пишите текст.
В моем примере использовал css.
public function fillCssField($css, $value)
{
$this->getSession()->getPage()->find('css', $css)->setValue($value);
}
Вот кусок самого теста. Не забываем в конце выходить с iframe для продолжения теста.
Then the iframe in element "cke_1_contents" has id "test"
And I switch to iframe "test"
And I fill in field ".cke_editable" with "text"
And I switch to window ""
And I save settings
Добавьте категорию Behat для темы.