페이지를 보면 클래스 바닥 글과 div가 표시되지 않았습니다. 이것이 요소를 찾을 수없는 이유 일 수 있습니다.
나를 위해, 마지막으로 보이는 요소는 바탕 화면 인 것처럼 보입니다. 즉, div와 class pic이 있습니다. 마지막 사진을 가져 와서 다음을 사용하여 스크롤 할 수 있습니다. 우리는 모든 그림을 찾은 다음 컬렉션에서 마지막 그림을 가져옵니다.
last_picture = driver.find_elements(:css, 'div.pic').last
last_picture.location_once_scrolled_into_view
마지막 배경 화면으로 스크롤 한 후 페이지로드가 완료 될 때까지 기다리는 것이 좋습니다. 예를 들어, 다음 이미지 카운트가 증가 될 때까지 기다립니다 :
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :firefox
driver.navigate.to 'http://www.mobileswall.com/'
# Check how many elements are there initially
puts driver.find_elements(:css, 'div.pic').length
#=> 30
# Scroll to the last image
driver.find_elements(:css, 'div.pic').last.location_once_scrolled_into_view
# Wait for the additional images to load
current_count = driver.find_elements(:css, 'div.pic').length
until current_count < driver.find_elements(:css, 'div.pic').length
sleep(1)
end
# Check how many elements are there now
puts driver.find_elements(:css, 'div.pic').length
#=> 59
좋은 아이디어는 HTML 문서를 제공하는 것입니다 .. 내가 링크 내 질문을 편집 –
@ArupRakshit, 당신은 나를 도와 드릴까요? 고맙습니다! –
페이지가 동적으로로드되고 있습니다. –