1
import openpyxl
from selenium import webdriver
from bs4 import BeautifulSoup
from selenium.webdriver.chrome.options import Options
wb = openpyxl.Workbook()
chrome_options = Options()

options = webdriver.ChromeOptions()
#options.add_argument('headless')
options.add_argument('window-size=1920x1080')
options.add_argument("disable-gpu")

sheet = wb.active
sheet.append(["1lable", "2lable"])
wb.save("save.xlsx")
path = "/Users/erer/Desktop/도구/파이썬 작업공간./chromedriver 2"

driver = webdriver.Chrome(path , chrome_options=options)

driver.get('https://otr.co.kr/#!')

driver.find_element_by_css_selector("#site-header > div > a").click()
driver.find_element_by_css_selector("#login-panel-1767 > form > div > div > div.form-group.label-floating.is-empty.is-focused").click()
driver.find_element_by_css_selector("#login-panel-1767 > form > div > div > div.form-group.label-floating.is-empty.is-focused").send_keys(" (개인정보라 비워둡니다.) ")
driver.find_element_by_css_selector("#login-panel-1205 > form > div > div > div.form-group.label-floating.password-eye-wrap.is-empty > input").send_keys("비밀번호라 비워둡니다.")
driver.find_element_by_css_selector("#login-panel-1205 > form > div > div > button").click()

https://otr.co.kr/#!

If you go into this link and press login popup on the top right, a popup that allows you to log in will be executed. Even if you apply css selectors, and other things in Selenium, you can't enter your ID password. I need the help of experts.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
김진우
  • 11
  • 2

2 Answers2

1

To send a character sequence to ID field you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    driver.get("https://otr.co.kr/?ckattempt=1")
    WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"a.side-menu-open>i.olympus-icon-Active-Members-Icon"))).click()
    WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"div#registration-login-form-popup input.form-control.simple-input[name='log']"))).send_keys("김진우")
    
  • Browser Snapshot:

otr_ko_kr

  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

You are using wrong locators and missing waits / delays.
Try this, it should work

import openpyxl
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from bs4 import BeautifulSoup
from selenium.webdriver.chrome.options import Options
wb = openpyxl.Workbook()
chrome_options = Options()

options = webdriver.ChromeOptions()
#options.add_argument('headless')
options.add_argument('window-size=1920x1080')
options.add_argument("disable-gpu")

sheet = wb.active
sheet.append(["1lable", "2lable"])
wb.save("save.xlsx")
path = "/Users/erer/Desktop/도구/파이썬 작업공간./chromedriver 2"

driver = webdriver.Chrome(path , chrome_options=options)
wait = WebDriverWait(driver, 20)
driver.get('https://otr.co.kr/#!')

wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#site-header > div > a"))).click()
username = wait.until(EC.visibility_of_element_located((By.XPATH, "//div[@class='modal-content']//input[@name='log' and(@class='form-control simple-input')]")))
username.click()
username.send_keys(" (개인정보라 비워둡니다.) ")
pwd_input = wait.until(EC.visibility_of_element_located((By.XPATH, "//div[@class='modal-content']//input[@name='pwd' and(@class='form-control simple-input')]")))
pwd_input.send_keys("비밀번호라 비워둡니다.")
driver.find_element_by_xpath("//div[@class='modal-content']//button[@type='submit']").click()
Prophet
  • 32,350
  • 22
  • 54
  • 79