우리는 선택적 루프에서 호출을 래핑하여이 시나리오를 처리하는 셀레늄 위에 레이어를 작성했습니다. 그래서 당신은 할 줄 때 그것이 AutomatedTester 위에서 제안한 것과 유사한 일을 할 것
@browser.click "#my_button_id"
:
class Browser
def click(locator)
wait_for_element(locator, :timeout => PAGE_EVENT_TIMEOUT)
@selenium.click(locator)
end
def wait_for_element(locator, options)
timeout = options[:timeout] || PAGE_LOAD_TIMEOUT
selenium_locator = locator.clone
expression = <<EOF
var element;
try {
element = selenium.browserbot.findElement('#{selenium_locator}');
} catch(e) {
element = null;
};
element != null;
EOF
begin
selenium.wait_for_condition(expression, timeout)
rescue ::Selenium::SeleniumException
raise "Couldn't find element with locator '#{locator}' on the page: #{$!}.\nThe locator passed to selenium was '#{selenium_locator}'"
end
end
end
래퍼 또한 버튼/입력 라벨 등으로 검색 할 수 있도록 같은 다른 일을했다 (래퍼가 타이밍 문제를 해결할 수있을뿐만 아니라 우리가 거기에 넣은 것 중 하나 일뿐입니다.)
예, 작동하지만 각 Ajax 요청에서 기다리고있는 것을 지정해야합니다 . 나는 더 좋은 방법이 있어야한다고 생각합니다. –