헤드리스 Chrome 요소를 클릭 할 수 없음 (브라우저 모드에서 작동)

함께

Selenium을 사용하여 스크립트를 작성했으며 브라우저 모드에서 작동합니다. 그러나 헤드리스 모드에서 시도하면 더 이상 작동하지 않습니다. 창 크기를 화면 해상도로 변경하는 인수를 추가했습니다. 그러나 여전히 문제가 해결되지 않았습니다. 이상한 점은 일부 버튼이 작동하지만 다른 버튼은 작동하지 않는다는 것입니다. 무슨 일이 일어나고 있는지 잘 모르겠습니다.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
import time
user_input='xyz'
def get_sequence():
    options = Options()
    options.add_argument("--window-size=1920,1080");
    options.add_argument("--start-maximized");
    options.add_argument("--headless");
    driver = webdriver.Chrome(options=options)
    driver.get('https://clims4.genewiz.com/RegisterAccount/Login')
    fill_box = driver.find_element_by_xpath('//*[@id="LoginName"]')
    fill_box.clear()
    fill_box.send_keys('*****')
    fill_box = driver.find_element_by_xpath('//*[@id="Password"]')
    fill_box.send_keys('*****')
    driver.find_element_by_xpath('//*[@id="btnSubmit"]').click()
    table = driver.find_element_by_xpath('//*[@id="myOrdersTable"]/tbody')
    for i,td in enumerate(table.find_elements_by_xpath('//*[@id="myOrdersTable"]/tbody/tr/td[4]'),1):
        if td.text == user_input:
            driver.find_element_by_xpath(f'//*[@id="myOrdersTable"]/tbody/tr[{i}]/td[11]/button').click()
            break

    time.sleep(5)
    seq_list=[]
    table=driver.find_element_by_xpath('//*[@id="gwzSngrOrderResultPanelRoot"]/table/tbody')
    for x,sequence in enumerate(table.find_elements_by_xpath('//*[@id="gwzSngrOrderResultPanelRoot"]/table/tbody/tr/td[9]'),1):
        driver.find_element_by_xpath(f'//*[@id="gwzSngrOrderResultPanelRoot"]/table/tbody/tr[{x}]/td[9]/span[2]').click()
        time.sleep(5)
        seq_info=driver.find_element_by_xpath('//*[@id="gwzViewResultsModalDialog"]/div/div/div[2]/div')
        seq_list.append([seq_info.text])
        driver.find_element_by_xpath('//*[@id="gwzViewResultsModalDialog"]/div/div/div[3]/button').click()
        time.sleep(5)

get_sequence():

위의 내용은 헤드리스 옵션 / 인수를 제거하면 작동합니다. 이것은 현재 위의 출력입니다.

[0705/143642.917:INFO:CONSOLE(66)] "visitorResponseData set", source: https://eastprodcdn.azureedge.net/bundles/legacy/velaro.inline.9b226ddb.js (66)
[0705/143644.640:INFO:CONSOLE(3)] "Hotjar not launching due to suspicious userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/83.0.4103.116 Safari/537.36", source: https://static.hotjar.com/c/hotjar-1144113.js?sv=6 (3)
[0705/143645.765:INFO:CONSOLE(66)] "visitorResponseData set", source: https://eastprodcdn.azureedge.net/bundles/legacy/velaro.inline.9b226ddb.js (66)
 driver.find_element_by_xpath(f'//*[@id="myOrdersTable"]/tbody/tr[{i}]/td[11]/button').click()
  File "C:\Users\Sams PC\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
    self._execute(Command.CLICK_ELEMENT)
  File "C:\Users\Sams PC\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "C:\Users\Sams PC\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Sams PC\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <button type="button" class="btn btn-sm gwz-grid-action" data-orderid="155e7035-5540-4fc5-8045-247511d0f7dc">...</button> is not clickable at point (1793, 959). Other element would receive the click: <div id="hs-eu-cookie-confirmation" class="hs-cookie-notification-position-bottom" data-nosnippet="">...</div>
  (Session info: headless chrome=83.0.4103.116)

가독성을 높이기 위해이 스크립트는 사이트로 이동하여 사이트 내의 테이블에서 user_input을 검색 한 다음 버튼을 클릭합니다. 그러면 새 페이지에 사용자가 클릭 한 버튼이있는 다른 테이블이 포함되어 추출 할 데이터가 포함 된 팝업이 생성됩니다.

편집 : 다음은 내가 시도한 솔루션입니다.

options = Options()
    options.add_argument("--window-size=1920,1080")
    options.add_argument("--start-maximized")
    options.add_argument("--disable-gpu")
    options.add_argument('--disable-extensions')
    options.add_argument('--no-sandbox')
    options.add_argument("--headless")
    driver = webdriver.Chrome(options=options)

또한 브라우저 창 크기는 브라우저 모드 (작동했을 때)에서 1554,882 였으므로 다음을 추가했습니다.

driver.set_window_size(1554,842)

그리고 그것은 여전히 ​​작동하지 않았습니다. 이것은 브라우저 크기 문제가 아닙니다.

함께

문제를 해결하고 쿠키를 사용하는 사이트에 대한 팝업이었습니다. 이전에 이미 해당 팝업을 수락했고 사이트에서 나를 기억했기 때문에 브라우저 모드에서는 표시되지 않았습니다. 또한 페이지 하단에 있었기 때문에 다른 버튼에도 영향을 미치지 않았습니다 (버튼 중 하나와 겹치는 부분, wrror를 제공하는 버튼). 시크릿 모드를 사용하여 다시 팝업되도록하고 해당 요소를 가져 와서 나머지 스크립트를 진행하기 전에 해당 버튼을 클릭하는 추가 줄을 추가 할 수있었습니다.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

헤드리스 모드에서는 요소를 클릭 할 수 없습니다.

분류에서Dev

UiPath가 Chrome 브라우저 팝업 대화 상자를 클릭 할 수 없음

분류에서Dev

Chrome 드라이버 서버에서 Chrome 브라우저를 시작할 수 없습니다.

분류에서Dev

Chrome 및 Mozilla Firefox 브라우저 모두에서 DhtmlxGrid의 텍스트를 복사 할 수 없음

분류에서Dev

Chrome 브라우저에 표시된 Base64 인코딩 PDF를 다운로드 할 수 없음

분류에서Dev

C #-Chrome 테스트가 포함 된 Selenium : 지점에서 요소를 클릭 할 수 없음 다른 요소가 클릭을 수신함

분류에서Dev

Glamour 브라우저 내에서 Roassal 시각화에서 가장자리를 클릭 할 수 없도록 설정

분류에서Dev

인쇄 미리보기가 열릴 때 Chrome 브라우저가 서버를 호출 할 수 없음

분류에서Dev

IE 브라우저에서 요소를 검사 할 수 없음-Selenium

분류에서Dev

Python-Firefox를 통한 Tor 브라우저, 버튼을 클릭 할 수 없음

분류에서Dev

탐색 모음에서 드롭 다운 메뉴를 클릭 할 수 없음

분류에서Dev

Chrome 브라우저 문제 : 내 웹 사이트의 링크를 클릭 할 수 없습니다.

분류에서Dev

브라우저를 통해 WebDav를 탐색 할 수 있지만 드라이브에 매핑 할 수 없음

분류에서Dev

Selenium에서 Chrome 헤드리스를 열 수 없음

분류에서Dev

Selenium 그리드의 Opera 브라우저 : 드라이버 클래스를 찾을 수 없음

분류에서Dev

Chrome 브라우저의 크기를 조정할 때까지 DOM 요소가로드되지 않습니다 (Safari에서 완벽하게 작동).

분류에서Dev

Selenium에서 사용자 프로필로 Chrome 브라우저를 시작할 수 없습니다.

분류에서Dev

내 HTML 버튼 요소를 클릭 할 수 없지만 키보드 단축키는 작동합니다.

분류에서Dev

간단한 익스프레스 코드의 경우 브라우저에 이미지를 표시 할 수 없음

분류에서Dev

Rainbow Wheel에서 앵커 요소를 클릭 할 수 없음

분류에서Dev

웹 드라이버를 사용하는 크롬 브라우저의 iframe 안에있는 버튼을 클릭 할 수 없습니다.

분류에서Dev

브라우저에서 Docker Tomcat에 액세스 할 수 없음

분류에서Dev

마우스 가리 키기 동작-숨겨진 링크를 클릭 할 수 없음

분류에서Dev

자동화 된 클라우드 빌드 중에 Google 소스 저장소를 가져올 수 없음

분류에서Dev

모바일 사파리에서 고정 위치 요소를 클릭 할 수 없음

분류에서Dev

셀레늄 + 자바를 통해 Google 드라이브 요소를 클릭 할 수 없습니다.

분류에서Dev

내 앱에서 웹 브라우저를 시작하고 클릭 한 URL을 반환 할 수 있습니까?

분류에서Dev

PHP 시작 : 동적 라이브러리를로드 할 수 없음 (NEW RELIC)

분류에서Dev

Windows 10에서 모든 Google Chrome 프로세스를 닫을 수 없으며 브라우저를 실행할 수 없습니다.

Related 관련 기사

  1. 1

    헤드리스 모드에서는 요소를 클릭 할 수 없습니다.

  2. 2

    UiPath가 Chrome 브라우저 팝업 대화 상자를 클릭 할 수 없음

  3. 3

    Chrome 드라이버 서버에서 Chrome 브라우저를 시작할 수 없습니다.

  4. 4

    Chrome 및 Mozilla Firefox 브라우저 모두에서 DhtmlxGrid의 텍스트를 복사 할 수 없음

  5. 5

    Chrome 브라우저에 표시된 Base64 인코딩 PDF를 다운로드 할 수 없음

  6. 6

    C #-Chrome 테스트가 포함 된 Selenium : 지점에서 요소를 클릭 할 수 없음 다른 요소가 클릭을 수신함

  7. 7

    Glamour 브라우저 내에서 Roassal 시각화에서 가장자리를 클릭 할 수 없도록 설정

  8. 8

    인쇄 미리보기가 열릴 때 Chrome 브라우저가 서버를 호출 할 수 없음

  9. 9

    IE 브라우저에서 요소를 검사 할 수 없음-Selenium

  10. 10

    Python-Firefox를 통한 Tor 브라우저, 버튼을 클릭 할 수 없음

  11. 11

    탐색 모음에서 드롭 다운 메뉴를 클릭 할 수 없음

  12. 12

    Chrome 브라우저 문제 : 내 웹 사이트의 링크를 클릭 할 수 없습니다.

  13. 13

    브라우저를 통해 WebDav를 탐색 할 수 있지만 드라이브에 매핑 할 수 없음

  14. 14

    Selenium에서 Chrome 헤드리스를 열 수 없음

  15. 15

    Selenium 그리드의 Opera 브라우저 : 드라이버 클래스를 찾을 수 없음

  16. 16

    Chrome 브라우저의 크기를 조정할 때까지 DOM 요소가로드되지 않습니다 (Safari에서 완벽하게 작동).

  17. 17

    Selenium에서 사용자 프로필로 Chrome 브라우저를 시작할 수 없습니다.

  18. 18

    내 HTML 버튼 요소를 클릭 할 수 없지만 키보드 단축키는 작동합니다.

  19. 19

    간단한 익스프레스 코드의 경우 브라우저에 이미지를 표시 할 수 없음

  20. 20

    Rainbow Wheel에서 앵커 요소를 클릭 할 수 없음

  21. 21

    웹 드라이버를 사용하는 크롬 브라우저의 iframe 안에있는 버튼을 클릭 할 수 없습니다.

  22. 22

    브라우저에서 Docker Tomcat에 액세스 할 수 없음

  23. 23

    마우스 가리 키기 동작-숨겨진 링크를 클릭 할 수 없음

  24. 24

    자동화 된 클라우드 빌드 중에 Google 소스 저장소를 가져올 수 없음

  25. 25

    모바일 사파리에서 고정 위치 요소를 클릭 할 수 없음

  26. 26

    셀레늄 + 자바를 통해 Google 드라이브 요소를 클릭 할 수 없습니다.

  27. 27

    내 앱에서 웹 브라우저를 시작하고 클릭 한 URL을 반환 할 수 있습니까?

  28. 28

    PHP 시작 : 동적 라이브러리를로드 할 수 없음 (NEW RELIC)

  29. 29

    Windows 10에서 모든 Google Chrome 프로세스를 닫을 수 없으며 브라우저를 실행할 수 없습니다.

뜨겁다태그

보관