вот так это выглядит в питон и работает замечательно:
вам нужно добавить для своего языка следующее:
import logging
from selenium.webdriver.remote.remote_connection import LOGGER
LOGGER.setLevel(logging.DEBUG)
# LOGGER.setLevel(logging.ERROR)
# LOGGER.setLevel(logging.INFO)
# LOGGER.setLevel(logging.WARN)
- в файле geckodriver.log по умолчанию пишется весь лог
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
import sqlite3
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import UnexpectedAlertPresentException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait
import logging
from selenium.webdriver.remote.remote_connection import LOGGER
LOGGER.setLevel(logging.DEBUG)
# LOGGER.setLevel(logging.ERROR)
# LOGGER.setLevel(logging.INFO)
# LOGGER.setLevel(logging.WARN)
# # Set the threshold for selenium to WARNING
# from selenium.webdriver.remote.remote_connection import LOGGER as seleniumLogger
# seleniumLogger.setLevel(logging.WARNING)
def send_delayed_keys(element, text, delay=0.3) :
for c in text :
endtime = time.time() + delay
element.send_keys(c)
time.sleep(endtime - time.time())
#con = sqlite3.connect(r'F:\db\Telegram_Bot\Base.db')
#base = con.execute(f"SELECT * FROM Passport").fetchall()
#for result in base:
# try:
# con.execute(f"ALTER TABLE Passport ADD COLUMN INN TEXT")
# except:
# pass
# options = webdriver.ChromeOptions()
# options.add_experimental_option('excludeSwitches', ['enable-logging'])
# browser = webdriver.Chrome(executable_path='/home/ru/webdriver/chromedriver', options=options)
options = webdriver.FirefoxOptions()
# options.add_argument('excludeSwitches', ['enable-logging'])
# options.log(LOGGER)
# options.add_argument("--log-level=3")
browser = webdriver.Firefox(executable_path='/home/ru/webdriver/geckodriver', options=options)
browser.get('https://service.nalog.ru/inn.do')
timeout = 5
wait = WebDriverWait(browser, timeout)
browser.find_element(By.ID, 'unichk_0').click()
browser.find_element(By.CLASS_NAME,'btn-next').click()
# fAMILY_1 = result[0]
# nAME_1 = result[1]
# fATHERNAME_1 = result[2]
# bIRTHDAY = result[7]
# pASSP_SERIES = result[9]
# pASSP_NUMBER = result[10]
# dELIVERYDATE = result[11]
time.sleep(2)
# import Action chains
from selenium.webdriver.common.action_chains import ActionChains
action = ActionChains(browser)
import pyperclip
pyperclip.copy('1234567 АБВГДЕЖЗИКЛМНОПРСТУФ')
for i in range(5):
browser.find_element(By.NAME,'nam').clear()
browser.find_element(By.NAME,'nam').click()
time.sleep(1)
# browser.find_element(By.NAME,'nam').send_keys("АБВГДЕЁЖЗИКЛМНОПРСТУФ")
# time.sleep(1)
# ActionChains(browser).send_keys_to_element(browser.find_element(By.NAME,'nam'), "абвгдеёжзийклмнопрстуа").perform()
# time.sleep(2)
# ActionChains(browser).send_keys_to_element(browser.find_element(By.NAME,'nam'), Keys.CONTROL + 'v').perform()
# ActionChains(browser).key_down(Keys.CONTROL).send_keys('V').perform()
# ActionChains(browser).key_down(Keys.TAB).perform()
# pyperclip.paste()
# browser.find_element(By.NAME,'nam').send_keys("АБВГДЕЁЖЗИКЛМНОПРСТУФ")
send_delayed_keys(browser.find_element(By.NAME,'nam'), "АБВГДЕЁЖЗИКЛМНОПРСТУФ", 0.2)
time.sleep(2)
browser.find_element(By.NAME,'fam').send_keys("абвгдеёжзийклмнопрстуа")
time.sleep(1)
browser.find_element(By.NAME,'nam').click()
time.sleep(1)
browser.find_element(By.NAME,'nam').send_keys("АБВГДЕЁЖЗИКЛМНОПРСТУФ")
time.sleep(1)
browser.find_element(By.NAME,'otch').send_keys("КЛИНИЧЕСКИЙ")
time.sleep(1)
browser.find_element(By.NAME,'bdate').send_keys("25071998")
time.sleep(2)
# import Action chains
# from selenium.webdriver.common.action_chains import ActionChains
# action = ActionChains(browser)
# action.click(on_element = browser.find_element(By.NAME,'fam')).perform()
# action.send_keys("абвгдеёжзийклмнопрстуа").perform()
browser.execute_script(f"document.getElementsByName('lfam').value='АБВГДЕЁЖЗИКЛМНОПРСТУФ'")
time.sleep(21)
browser.close()
начало лога в geckodriver.log:
1679644019435 geckodriver INFO Listening on 127.0.0.1:37917
1679644019440 mozrunner::runner INFO Running command: "/usr/bin/firefox" "--marionette" "--log-level=3" "--remote-debugging-port" "43323" "--remote-allow-hosts" "localhost" "-no-remote" "-profile" "/tmp/rust_mozprofilezY99Pj"
console.warn: services.settings: Ignoring preference override of remote settings server
console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment
ATTENTION: default value of option mesa_glthread overridden by environment.
ATTENTION: default value of option mesa_glthread overridden by environment.
ATTENTION: default value of option mesa_glthread overridden by environment.
ATTENTION: default value of option mesa_glthread overridden by environment.
1679644020842 Marionette INFO Marionette enabled
1679644020849 Marionette INFO Listening on port 36047
console.error: "Warning: unrecognized command line flag -log-level\n"
Read port: 36047
WebDriver BiDi listening on ws://127.0.0.1:43323
1679644021031 RemoteAgent WARN TLS certificate errors will be ignored for this session
console.error: ({})
console.warn: SearchSettings: "get: No settings file exists, new profile?" (new NotFoundError("Could not open the file at /tmp/rust_mozprofilezY99Pj/search.json.mozlz4", (void 0)))
DevTools listening on ws://127.0.0.1:43323/devtools/browser/9081a826-057a-4afd-8b61-e649d97aaa4c
console.warn: LoginRecipes: "Falling back to a synchronous message for: https://service.nalog.ru."
1679644093586 Marionette INFO Stopped listening on port 36047
1679644094585 geckodriver INFO Listening on 127.0.0.1:51725
1679644094591 mozrunner::runner INFO Running command: "/usr/bin/firefox" "--marionette" "--remote-debugging-port" "48103" "--remote-allow-hosts" "localhost" "-no-remote" "-profile" "/tmp/rust_mozprofilehr069X"
console.warn: services.settings: Ignoring preference override of remote settings server
console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment
ATTENTION: default value of option mesa_glthread overridden by environment.