如何使用Selenium和Web Driver单击MetAmask使用Python启动Botton
我试图与Selenium在Python上进行Web scraper,涉及DAPP,我需要使用MetAmask登录以刮擦信息,但我无法在MetAmask的Start Botton上进行。也许你们中的一些人可以提供帮助。也许有人可以帮助我理解为什么我的代码不起作用。
我试图搜索此不同的代码标签,但我仍然无法单击:
1-driver.find_element_by_xpath('//button[text()="Empezar"]').click()
2-driver.find_element_by_xpath('//button[text()="Get Started"]').click()
3-WebDriverWait(driver, 5)\
.until(EC.element_to_be_clickable((By.CSS_SELECTOR,
'button.button btn--rounded btn-primary first-time-flow__button'.replace(' ', '.'))))\
.click()
这是我的代码。它打开MetAmask Landpage,但随后并未在classs =“ button btn-indour btn-primary首次first first-flow__button上”上的“启动”标签上。
#Librerias
from selenium import webdriver
from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time
#
Añadir Chrome options
chrome_options = ChromeOptions()
chrome_options.add_argument('--start-maximized')
#Ruta de metamask.crx para inicializar la aplicación
chrome_options.add_extension(r"C:\\Users\\34625\\OneDrive\\Luisyluis\\OneDrive\\Documentos\\Proectos Personales\\programacion 2022\\Programacion Meta Soccer\\Metasoccerr\\metamask.crx")
#Opciones de Navegación
driver_path ='A:\WebDriver\chromedriver.exe'
driver = webdriver.Chrome(driver_path,options=chrome_options)
enter code here
#METAMASK - Click Empezar -- !!! THIS DOESN´T WORK
time.sleep(3)
driver.find_element_by_xpath(
'//button[text()="Empezar"]').click()
Im trying to do a web scraper on python with selenium about an dapp where I need to log in with Metamask to scrape the information but I can´t clic on the start botton of Metamask. Maybe some of you can help. Maybe someone could help me understand why my code doesn't work.
I have tried to search the tag whit this diferent code but I still cant click:
1-driver.find_element_by_xpath('//button[text()="Empezar"]').click()
2-driver.find_element_by_xpath('//button[text()="Get Started"]').click()
3-WebDriverWait(driver, 5)\
.until(EC.element_to_be_clickable((By.CSS_SELECTOR,
'button.button btn--rounded btn-primary first-time-flow__button'.replace(' ', '.'))))\
.click()
This is my code. It opens metamask landpage but then it doesnt clic on the "Start" tag with classs = "button btn--rounded btn-primary first-time-flow__button".
#Librerias
from selenium import webdriver
from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time
#
Añadir Chrome options
chrome_options = ChromeOptions()
chrome_options.add_argument('--start-maximized')
#Ruta de metamask.crx para inicializar la aplicación
chrome_options.add_extension(r"C:\\Users\\34625\\OneDrive\\Luisyluis\\OneDrive\\Documentos\\Proectos Personales\\programacion 2022\\Programacion Meta Soccer\\Metasoccerr\\metamask.crx")
#Opciones de Navegación
driver_path ='A:\WebDriver\chromedriver.exe'
driver = webdriver.Chrome(driver_path,options=chrome_options)
enter code here
#METAMASK - Click Empezar -- !!! THIS DOESN´T WORK
time.sleep(3)
driver.find_element_by_xpath(
'//button[text()="Empezar"]').click()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我是使用硒的新鲜,我也发现了这个问题。我已经尝试过很多次,直到我尝试在下面尝试使用此代码之前。 Python版本:3.11.5
(您需要更改
alkhkbbpfhhhihonfljaopkepepepefjicohg
to您自己的扩展ID)。之后,当我在下面运行此代码时,我可以获取输入元素:代表复选框按钮。
希望这个答案能有所帮助。
I'm a fresher to use selenium, I found this problem, too. I had tried many times until I tried to use this code below before I got element. Python version: 3.11.5
(you need to change
alkhkbbpfhhihonfljaopkepefjicohg
to your own extension id). after that I can get the input element when I run this code below:which is represent the checkbox button.
Hope this answer can be helpful.