inflearn logo
강의

講義

知識共有

[新規改訂版] これが本当のエクセル自動化だ - 基本編

Excelファイルを自分の好きなように操作する

크롬창이 자꾸 꺼져요!!

912

sellytop2

投稿した質問数 2

0

 from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager

chrome_options = Options()
chrome_options.add_experimental_option("detach", True) 
service = Service(executable_path=ChromeDriverManager().install())
webdriver.Chrome(service=service, options=chrome_options)
chrome_options.add_experimental_option("excludeSwitches",["enable-logging"])
driver = webdriver.Chrome() 
driver.get('https://nid.naver.com/nidlogin.login?svctype=262144')
driver.maximize_window()

id = driver.find_element(By.CSS_SELECTOR, "#id")
id.send_keys("제 네이버 아이디 입니당")

ㅜㅜ자꾸 크롬창이 꺼지는데 어떻게 해야할까요

 

좋은 강의 항상 감사합니다! ;)

 

 

python selenium openpyxl

回答 1

1

communityai8509

안녕하세요, 인프런 AI 인턴입니다. sellytop2님, 문제 해결을 위해 도움을 드리겠습니다.

코드를 살펴보면 webdriver.Chrome() 이 두 번 호출되고 있어서 문제가 발생할 가능성이 있습니다. 첫 번째는 옵션을 포함하여 웹드라이버를 초기화 하고, 두 번째는 옵션 없이 새로운 웹드라이버 인스턴스를 생성하고 있습니다. 이로 인해 첫 번째로 생성된 브라우저 창이 바로 닫히게 될 수 있습니다.

또한, chrome_options.add_experimental_option("excludeSwitches",["enable-logging"]) 코드가 webdriver.Chrome(service=service, options=chrome_options) 호출 이후에 있어서 실제로 적용되지 않고 있습니다. 이 옵션은 웹드라이버를 초기화하기 전에 설정되어야 합니다.

코드를 수정하기 위해서는 다음과 같이 조정하시면 됩니다:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager

chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
chrome_options.add_experimental_option("excludeSwitches", ["enable-logging"])
service = Service(executable_path=ChromeDriverManager().install())

# WebDriver 초기화 시 옵션을 넣어줍니다.
driver = webdriver.Chrome(service=service, options=chrome_options)

driver.get('https://nid.naver.com/nidlogin.login?svctype=262144')
driver.maximize_window()

id = driver.find_element(By.CSS_SELECTOR, "#id")
id.send_keys("제 네이버 아이디 입니당")

이렇게 수정하면, 설정한 옵션들이 제대로 적용되어 실행 중인 크롬 창이 닫히지 않을 것입니다. 문제가 계속된다면 추가적인 설정이나 다른 문제점을 확인해야 할 수도 있습니다. 도움이 되셨길 바랍니다!

선생님 셀에서 전체 실행은 어떻게하나요?

0

86

2

전자는 보안때매 안되나요?

0

150

2

보고서, 데이터, 계산서 자동 정리 프로그램 오류

0

208

1

사이트 접속 후 로그인 버튼 클릭 시 문제점

0

280

3

엑셀 파일 제목 중복되면 (1),(2) 씩 늘어나게 해서 생성하게 하기

0

407

1

엑셀 다루기 기초에서 날짜 1일씩 늘어나게 하기

0

847

1

mouseInfo

0

284

1

pyautogui.mousInfo() 질문(영상 11:03)

0

221

2

네이버 메일 자동화 실습 문의

0

372

1

pip명령이 vscode 명령프롬프트에서만 않되네요

0

4450

2

매출데이터 생성 price 오류

0

366

2

네이버 자동화 실습 관련 질의

0

448

1

pyautogui.center(pyautogui.locateOnScreen('wmp.PNG', grayscale=True, confidence=0.7)) 좌표 이상

0

538

2

블로그에 강의 코드를 정리해서 올려도 괜찮을까요??

0

408

1

Chrome version 116, Selenium version 4.11.2 이후

0

719

1

python upgrade 후 selenium 인식 불가

0

810

1

Google Chrome 업데이트 이후 크롬드라이브 실행 오류

0

2158

2

크롬드라이브 실행 오류

1

15385

4

오프라인 pip설치문의

0

1232

2

네이버 메일 자동화, 메일 창이 새탭에 생성

0

908

1

팝업 설명창?

0

419

1

셀레니움 기초 사용법

0

545

1

키보드 자동화_소문자 ko 입력 안되는 이유 질문 드려요

0

487

1

TypeError: 'module' object is not callable 이런 오류가 뜹니다

0

733

1