location_once_scrolled_into_view 함수가 작동이 안됩니다.

조회수 1833회
from bs4 import BeautifulSoup
import requests
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from urllib.request import urlopen
import time


try:
   driver=webdriver.Chrome()
   url='자회사 url'
   r=requests.get(url)
   soup=BeautifulSoup(r.text,"html.parser")
   mr=str(soup.find(class_="ABA-article-contents" ))






   driver.get('http://cafe.naver.com/joonggonara')


   login=driver.find_element_by_class_name('gnb_txt')

   login.location_once_scrolled_into_view
   login.click()
   id=driver.find_element_by_id('id')
   id.send_keys('아이디')
   pw=driver.find_element_by_id('pw')
   pw.send_keys('비밀번호')

   login=driver.find_element_by_class_name('btn_global')
   login.click()

   menu=driver.find_element_by_xpath('//*[@id="menuLink0"]')
   menu.click()
   cafe_write= driver.find_element_by_xpath('//*[@id="cafe-info-data"]/div[3]/a/img')
   cafe_write.click()

   driver.switch_to_frame(driver.find_element_by_id("cafe_main"))
   select=driver.find_element_by_xpath('//*[@id="boardCategory"]')
   select.click()
   select=driver.find_element_by_xpath('//*[@id="boardCategory"]/option[2]')
   select.click()
   subject=driver.find_element_by_xpath('//*[@id="subject"]')
   subject.send_keys('테스트')
   write=driver.find_element_by_xpath('//*[@id="toolbox"]/tbody/tr[4]/td')
   htmlck=driver.find_element_by_xpath('//*[@id="elHtmlMode"]')
   htmlck.click()
   ac=ActionChains(driver)
   ac.move_to_element(write)
   ac.click()
   ac.send_keys('테스트')
   ac.perform()
   ac.reset_actions
   editor=driver.find_element_by_xpath('//*[@id="naver_common_editor"]/h3/img')
   editor.click()
   view=driver.find_element_by_xpath('//*[@id="nboard"]/div[3]/a[3]')
   view.location_once_scrolled_into_view #<--문제의 코드
   view.click()

자회사 컨텐츠를 파싱하여 다른 커뮤니티에 작성하는 프로그램을 코딩 중에 있습니다. 제목과 글쓰기는 파싱하여 출력을 완료했는데, '글작성' 버튼을 찾아 클릭하니 찾을 수 없다고 나옵니다.

원인은 스크린안에서 글작성 버튼이 가려져 있어서 마우스가 찾을 수 없는 것이었는데, 이를 해결하려 location_once_scrolled_into_view 코드를 사용하였는데 다른 구문에서는 먹히는데 위 코드에서 볼 수 있는 위치에서만 정상적으로 작동이 되질 않습니다.

아무리 찾아봐도 이유를 알 수 없어 해결 방안을 알려주셨으면 하는 마음으로 질문드립니다.

  • (•́ ✖ •̀)
    알 수 없는 사용자

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)