Home > Software design >  My function click() dont work with href of this site, how i can fix and make work?
My function click() dont work with href of this site, how i can fix and make work?

Time:02-12

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
#Service("local do diretorio do chromeDriver")

driver = webdriver.Firefox('/home/arch/Downloads/bot/')
driver.get("https://blaze.com/pt/?modal=auth&tab=login")

element=driver.find_element_by_name("username").send_keys("email")
driver.find_element_by_name("password").send_keys("pass")
#link da url desejada

driver.find_element_by_xpath('/html/body/div[1]/main/div[3]/div/div[2]/div[2]/form/div[4]/button').click()
driver.find_element_by_xpath('/html/body/div[1]/main/div[1]/div[4]/div[2]/div[1]/div/div/div[4]/div[1]/div/div[3]/div/a')

I have this code in python that opens in blazer.com and makes login but when i try to click o game mines which in this href:

<a href="/pt/games/mines"/>

and doesnt work justs stops , someone could help with this error

CodePudding user response:

You probably forgot to click the "mines" button. Don't forget the .click() at the end of your code, like this:

driver.find_element_by_xpath('/html/body/div[1]/main/div[1]/div[4]/div[2]/div[1]/div/div/div[4]/div[1]/div/div[3]/div/a').click()

And you also might want to give the site some time to load by importing time and using time.sleep(x) which sleeps the code for x seconds.

import time

time.sleep(2) # Use this between the .click() lines to give the site time to load after clicking a button
  • Related