로드 된 페이지의 모든 링크를 크롤링하고 모든 요청 및 응답 헤더를 응답 본문과 함께 일부 파일에 XML 또는 txt로 기록하는 크롤러를 작성하려고합니다.캐시에 요소가 없습니다. Selenium Ruby 웹 드라이버에서 찾은 페이지가 변경되었을 수 있습니다.
Element not found in the cache - perhaps the page has changed since it was looked up
내가 요청을하고 모든 링크에서 응답을 수신 한 후 입력을 찾을 수있는 다른 방법이 될 수 있는지 알고 싶어 : 나는 그래서 늘이 오류가 새 브라우저 창에서 처음로드 페이지에서 모든 링크를 개방하고 요소 및 제출 버튼은 열려있는 모든 창을 형성합니다. 위 오른쪽 코너에있는이 http://www.testfire.net에있는 것과 같은 공용 사이트 검색 박스가 열려있는 창을 제외하고, 어느 정도 위에 할 수 있습니다. 내가 뭘하고 싶은지 일반 입력란을 생략하여 i.send_keys "value"
webdriver 메서드를 사용하여 다른 입력 값을 채울 수 있으며이 오류가 발생하지 않습니다. 오류 : 캐시에서 요소를 찾을 수 없습니다 - 페이지가 변경되었을 수 있습니다. 쳐다 보았다.
열려있는 각 창에서 입력 태그를 감지하고 구분하여 대부분의 웹 사이트 페이지에 나타나는 공통 입력 태그에서 값이 반복적으로 채워지지 않게하는 방법은 무엇입니까? 내 코드는 다음입니다 : 내가 셀레늄 Webdriver를 사용하거나 루비의 net/http
의 http.set_debug_output
를 사용하여 응답 본문 모든 requeat 및 응답 헤더를 얻을 수있는 방법
require 'rubygems'
require 'selenium-webdriver'
require 'timeout'
class Clicker
def open_new_window(url)
@driver = Selenium::WebDriver.for :firefox
@url = @driver.get " http://test.acunetix.com "
@link = Array.new(@driver.find_elements(:tag_name, "a"))
@windows = Array.new(@driver.window_handles())
@link.each do |a|
a = @driver.execute_script("var d=document,a=d.createElement('a');a.target='_blank';a.href=arguments[0];a.innerHTML='.';d.body.appendChild(a);return a", a)
a.click
end
i = @driver.window_handles
i[0..i.length].each do |handle|
@driver.switch_to().window(handle)
puts @driver.current_url()
inputs = Array.new(@driver.find_elements(:tag_name, 'input'))
forms = Array.new(@driver.find_elements(:tag_name, 'form'))
inputs.each do |i|
begin
i.send_keys "value"
puts i.class
i.submit
rescue Timeout::Error => exc
puts "ERROR: #{exc.message}"
rescue Errno::ETIMEDOUT => exc
puts "ERROR: #{exc.message}"
rescue Exception => exc
puts "ERROR: #{exc.message}"
end
end
forms.each do |j|
begin
j.send_keys "value"
j.submit
rescue Timeout::Error => exc
puts "ERROR: #{exc.message}"
rescue Errno::ETIMEDOUT => exc
puts "ERROR: #{exc.message}"
rescue Exception => exc
puts "ERROR: #{exc.message}"
end
end
end
#Switch back to the original window
@driver.switch_to().window(i[0])
end
end
ol = Clicker.new
url = ""
ol.open_new_window(url)
나를 안내?