I want to click on the button to close the message that is being written.
I try with this code, but it does not work for me:
driver.find_element_by_xpath('//input[@type="Cerrar"]').click()
Can you help me? Thanks very much.
CodePudding user response:
You need to click this element: //img[@alt="Close"]
So, the Selenium python command to do this is
driver.find_element_by_xpath('//img[@alt="Close"]').click()
CodePudding user response:
unless your code needs to use selenium i think that pyautogui would be better for this. it can move your mouse to a specific coordinate or look for the close button and then click it
import pyautogui
pyautogui.moveTo(x=(your x), y=(your y))
pyautogui.click()
i dont know much about selenium so im sorry i cant use that to help you but i hope this helps.
CodePudding user response:
The built-in method close
:
The
close()
method is used to close the current browser window on which the focus is set, on the other hand, thequit()
method essentially calls the driver. dispose of a method that successively closes all the browser windows and ends the WebDriver session graciously.
You want to use click
when interacting with elements
driver.find_element_by_xpath('//input[@type="Cerrar"]').click()
If that doesn't work, please share the HTML code.