我在一个网站上有一个按钮,但它没有点击,即使我尝试通过xpath、id、类和其他方式查找元素。
这就是按钮的元素代码
<button type="button" class="gpbutton" id="gtltranslate">Translate</button>
这是我的代码,它打开一个文件并将它们转换成另一个文件
import os
from tkinter import *
from tkinter import filedialog
import selenium
import time
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium import webdriver
from selenium import webdriver
import contextlib as textmanager
PATH= "C:\Program Files (x86)\chromedrivers\chromedriver.exe"
driver= webdriver.Chrome(PATH)
eng=[]
driver.get("https://www.webtran.eu/finnish_english_translator/")
input1= driver.find_element_by_id("gtlsource")
output1= driver.find_element_by_id("gtlresults_body")
btn= driver.find_element_by_class_name("gpbutton")
lines= []
with open("sanat.txt", "r") as file:
for line in file:
line = line.strip() #or some other preprocessing
lines.append(line) #storing everything in memory!
k=0
while k != len(lines):
input1.send_keys(lines[k])
time.sleep(0.5)
btn.click()
time.sleep(0.5)
eng.append(output1)
input1.clear()
k=k+1
time.sleep(1)
这就是错误所在
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <button type="button" class="gpbutton" id="gtltranslate">...</button> is not clickable at point (534, 490). Other element would receive the click: <span id="cookieconsent:desc" class="cc-message">...</span>
(Session info: chrome=91.0.4472.124)
1条答案
按热度按时间okxuctiv1#
您需要以全屏模式启动浏览器:
然后像这样使用下面的css选择器:
进口:
ps:您可以在代码中使用如下屏幕最大化: