如何使用Selenium和Web Driver单击MetAmask使用Python启动Botton

发布于 2025-01-24 02:06:06 字数 1636 浏览 0 评论 0原文

我试图与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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沉溺在你眼里的海 2025-01-31 02:06:06

我是使用硒的新鲜,我也发现了这个问题。我已经尝试过很多次,直到我尝试在下面尝试使用此代码之前。 Python版本:3.11.5

    driver.get("chrome-extension://alkhkbbpfhhihonfljaopkepefjicohg/home.html");

(您需要更改alkhkbbpfhhhihonfljaopkepepepefjicohg to您自己的扩展ID)。之后,当我在下面运行此代码时,我可以获取输入元素:

    driver.find_element(By.CSS_SELECTOR, 'input').click()

代表复选框按钮。
希望这个答案能有所帮助。

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

    driver.get("chrome-extension://alkhkbbpfhhihonfljaopkepefjicohg/home.html");

(you need to change alkhkbbpfhhihonfljaopkepefjicohg to your own extension id). after that I can get the input element when I run this code below:

    driver.find_element(By.CSS_SELECTOR, 'input').click()

which is represent the checkbox button.
Hope this answer can be helpful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文