Open nurettinselcuk opened 2 years ago
Thank you for reporting this issue!
Unfortunately I do not have time to look into this issue now, I will try to do so in the coming days.
But I have three questions that may help resolve the issue. On the fourth line, you run a script:
driver.execute_script(script)
If so, does the script:
As the other issue opened today seems related, it might be there is a bug that causes both issues, which I will investigate.
If you got the error message ERROR:root:element could not be clicked on
in the console, you can try to replace the line:
kiminicin = driver.find_element_by_xpath('//span[text()="Hesap oluşturun"]/parent::button')
with:
kiminicin = driver.find_element_by_xpath('//span[text()="Hesap oluşturun"]')
as a temporary workaround until I have time to fix the underlying problem.
The problem is that the button is the parent node (/parent::button
) of the span (//span[text()="Hesap oluşturun"]
). The button is therefore hidden by the span, which is placed on top of the button. This is the reason why HLISA refuses to click on the button, and instead gives the message ERROR:root:element could not be clicked on
. This is by design, as a feature of HLISA is that is does not click on invisible buttons. But in this case, it is too strict, and I will change the behavior when I have more time.
Perhaps, it is considerable to have two modes: default and force.
Update: You are right, it is indeed too strict. A relative simple element, like the one below, cannot be clicked:
<a target="_blank" href="/login.php"> <b>Login</b> </a>
I think adding a check if the click hit a descendant should do the trick.
Thank you for implementing this solution!
Indeed, this check will do the trick in 99% of all cases. I suspect there will be a problem however in some cases, for example when a small button is placed on top of the larger button. Like the closing button on a browser tab. With this check in place, the smaller button can be clicked on by HLISA instead of the large button, if the small button is a child of the larger button. This can cause (non-deterministic) unexpected behavior (closing the tab instead of clicking on the tab, if the random coordinates are on the close button). It is not trivial to prevent this I think, but two possible solutions are:
But such situations will be very rare, so I am glad to merge your solution, which solves this problem in almost all instances, including the instance for which this issue was opened. I will leave the issue open for the low priority fix that addresses the 1% of cases mentioned above.
Hi,
`driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)
driver.maximize_window() driver.get('https://accounts.google.com/signin/v2/identifier?continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&service=mail&sacu=1&rip=1&flowName=GlifWebSignIn&flowEntry=ServiceLogin')
driver.execute_script(script) actions = HLISA_ActionChains(driver)
title = driver.find_element(By.XPATH, '//span[text()="Oturum aç"]/parent::h1')
kiminicin = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//span[text()="Hesap oluşturun"]/parent::button')))
kiminicin = driver.find_element_by_xpath('//span[text()="Hesap oluşturun"]/parent::button') actions.move_to_element(kiminicin).click(kiminicin).perform()`
HLISA clicks somewhere else, most probably clicks on 0,0.
Python version 3.6.8