작성
·
315
0
TypeError Traceback (most recent call last)Input In [20], in <cell line: 6>() 4 headlessoptions.add_argument('headless') 5 chromedriver = 'C:/dev_python/Webdriver/chromedriver.exe' ----> 6 driver = webdriver.Chrome(chromedriver, options=headlessoptions ) 7 driver.get('https://davelee-fun.github.io/') 9 elem = driver.find_element_by_tag_name("h1") TypeError: __init__() got an unexpected keyword argument 'options'
from selenium import webdriver headlessoptions = webdriver.ChromeOptions() headlessoptions.add_argument('headless') chromedriver = 'C:/dev_python/Webdriver/chromedriver.exe' driver = webdriver.Chrome(chromedriver, options=headlessoptions) driver.get('https://davelee-fun.github.io/') elem = driver.find_element_by_tag_name("h1") print (elem.text) driver.quit()
답변 1
0
셀레니움 버전 업데이트에서 다음과 같은 변화를 말함
Selenium 4.3.0
* Deprecated find_element_by_* and find_elements_by_* are now removed (#10712)
* Deprecated Opera support has been removed (#10630)
* Fully upgraded from python 2x to 3.7 syntax and features (#10647)
* Added a devtools version fallback mechanism to look for an older version when mismatch occurs (#10749)
* Better support for co-operative multi inheritance by utilising super() throughout
* Improved type hints throughout
따라서 강의에서 언급한 "find_element_by_tag_name"코드는 이제 지원하지 않음. find_element("tag name", "h1") 이 코드를 사용하면 원하는 결과를 얻을 수 있음.
셀레니움 변경사항은 링크 참고.
https://github.com/SeleniumHQ/selenium/blob/a4995e2c096239b42c373f26498a6c9bb4f2b3e7/py/CHANGES