wkeeling / selenium-wire

Extends Selenium's Python bindings to give you the ability to inspect requests made by the browser.
MIT License
1.86k stars 241 forks source link

selenium - same code - work well from mac book, but not work from windows machine #683

Closed jinho6225 closed 1 year ago

jinho6225 commented 1 year ago

Hi All,

I'm not sure it's OS issue trying to find out root cause, but was not able to find it

when I run my code from mac book, it works but, when I run my code from window machine, it's not working

here is my code

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from seleniumwire import webdriver
import time

options = webdriver.ChromeOptions()
# options.add_argument('headless')

browser = webdriver.Chrome(service=Service(ChromeDriverManager().install()), chrome_options=options)

def CheckNemoNo1():
  print('start scanning no1')  
  browser.get("https://www.nemoapp.kr/Search?SortBy=2&ArticleType=1&PageIndex=0&StoreTrade=true&SWLng=124.84087420672701&SWLat=36.914170545901285&NELng=130.4544927218148&NELat=39.04367294406773&Zoom=9&mode=1&category=1&list=true&articleId=&dataType=&utm_source=Naver_BrandSearch&utm_medium=cpc&utm_campaign=PC&utm_content=%ED%83%80%EC%9D%B4%ED%8B%80%EB%A7%81%ED%81%AC")
  time.sleep(2)
  close_btn = browser.find_element(By.CLASS_NAME, "btn_close")  
  close_btn.click()
  time.sleep(1)

CheckNemoNo1()

here is screenshot from mac book Screenshot-mac

here is screenshot from window

capture-window

when I refresh page, sometime I got this error mas 502 Bad Gateway TlsProtocolException('Cannot establish TLS with www.nemoapp.kr:443 (sni: www.nemoapp.kr): TlsException("SSL handshake error: SysCallError(-1, \'Unexpected EOF\')")')

this is error msg from terminal on windows machine


start scanning no1
Traceback (most recent call last):
  File "C:\Users\Joseph\Documents\kmong_nemo-main\a.py", line 23, in <module>
    CheckNemoNo1()
  File "C:\Users\Joseph\Documents\kmong_nemo-main\a.py", line 17, in CheckNemoNo1
    close_btn = browser.find_element(By.CLASS_NAME, "btn_close")
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 740, in find_element
    return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 346, in execute
    self.error_handler.check_response(response)
  File "C:\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".btn_close"}
  (Session info: chrome=114.0.5735.110); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
Backtrace:
        GetHandleVerifier [0x00F7A813+48355]
        (No symbol) [0x00F0C4B1]
        (No symbol) [0x00E15358]
        (No symbol) [0x00E409A5]
        (No symbol) [0x00E40B3B]
        (No symbol) [0x00E6E232]
        (No symbol) [0x00E5A784]
        (No symbol) [0x00E6C922]
        (No symbol) [0x00E5A536]
        (No symbol) [0x00E382DC]
        (No symbol) [0x00E393DD]
        GetHandleVerifier [0x011DAABD+2539405]
        GetHandleVerifier [0x0121A78F+2800735]
        GetHandleVerifier [0x0121456C+2775612]
        GetHandleVerifier [0x010051E0+616112]
        (No symbol) [0x00F15F8C]
        (No symbol) [0x00F12328]
        (No symbol) [0x00F1240B]
        (No symbol) [0x00F04FF7]
        BaseThreadInitThunk [0x76D000C9+25]
        RtlGetAppContainerNamedObjectPath [0x77C27B4E+286]
        RtlGetAppContainerNamedObjectPath [0x77C27B1E+238]```

anyone can help me out?
do you have any idea?
@wkeeling 
syx1031 commented 9 months ago

I'd like to know how to fix it, Thanks!

syx1031 commented 9 months ago

I had the exactly same problem!