-1

enter image description hereMy code is basically logging into a website (https://user.sensogram.com/signin) and download the CSV file by clicking on a button (Download CSV). However I am getting an errors that says:

File "c:\Users\USERPC\Desktop\python\sesno_login.py", line 57, in <module>
csv_file_button.click()

File "C:\Users\USERPC\AppData\Local\Programs\Python\Python36-32\lib\site- 
packages\selenium\webdriver\remote\webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)

File "C:\Users\USERPC\AppData\Local\Programs\Python\Python36-32\lib\site- 
packages\selenium\webdriver\remote\webelement.py", line 628, in _execute
return self._parent.execute(command, params)

File "C:\Users\USERPC\AppData\Local\Programs\Python\Python36-32\lib\site- 
packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
self.error_handler.check_response(response)

File "C:\Users\USERPC\AppData\Local\Programs\Python\Python36-32\lib\site- 
packages\selenium\webdriver\remote\errorhandler.py", line 242, in 
check_response raise exception_class(message, screen, stacktrace)

selenium.common.exceptions.WebDriverException: Message: unknown error: 
Element <tspan>...</tspan> is not clickable at point (1232, 413). Other 
element would receive the click: <div class="page-loading ng-scope" ng- 
if="showPreloader" style="">...</div>

It's like that the code can't locate the click button on the page for some reason. This is what I wrote so far:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.common.exceptions import NoSuchElementException
import time

chromedriver = "/webdrivers/chromedriver"
driver = webdriver.Chrome(chromedriver)
driver.maximize_window()
driver.get('https://user.sensogram.com/signin')   #driver.get(url)-- We get 
url by using driver which we initialy load.    
print ("Opened sensogram")
time.sleep(5)    #Just wait for sometime.
email = driver.find_element_by_xpath("//input[@name='usernameSignIn']") 
#Find email textaera.
email.send_keys('****')  #Send email to this text area. 
password = driver.find_element_by_xpath("//input[@name='passwordSignIn']") 
#Find password textarea.
password.send_keys('*******')   #send password to the password field.
button = driver.find_element_by_xpath("//button[@ng- 
click='submitted=true']")  #Find login button.
button.click()      #Click on login button. 
driver.implicitly_wait(10)
csv_file_button = driver.find_element_by_xpath("//*[name()='tspan' and 
.='Download CSV']")
csv_file_button.click()
print(csv_file_button)

can someone figure out why i Keep getting this type of error? plus this is the webpage HTML of the csv file:

<g class="highcharts-button highcharts-contextbutton highcharts-button- 
normal" style="cursor:pointer;vertical-align:center;font-size:12;font- 
weight:500;" stroke-linecap="round" transform="translate(379,8)"> 
<title>Chart context menu</title><rect fill="rgba(0, 0, 0, 0.7)" class=" 
highcharts- button-box" x="0.5" y="0.5" width="100" height="32" rx="2" 
ry="2" stroke="none" stroke-width="1"></rect><text x="7" style="font- 
weight:normal;color:#fff;fill:#fff;" y="19"><tspan>Download CSV</tspan> 
</text></g>
Moosa
  • 15
  • 4
  • Possible duplicate of [Element MyElement is not clickable at point (x, y)... Other element would receive the click](https://stackoverflow.com/questions/44724185/element-myelement-is-not-clickable-at-point-x-y-other-element-would-receiv) – undetected Selenium Apr 08 '18 at 16:34
  • Look at the error message. It tells you what the problem is. – JeffC Apr 08 '18 at 19:09
  • the thing is the button is located inside a chart and it's hard to locate it – Moosa Apr 08 '18 at 19:46
  • `Other element would receive the click:
    ...
    ` I'm assuming that `DIV` is displaying "Loading..." or something similar given the class `page-loading`. Try waiting for the loader `DIV`to be visible then invisible and then try your click.
    – JeffC Apr 08 '18 at 22:48
  • It just worked for me I just added time.sleep (5) after logging in – Moosa Apr 08 '18 at 23:04

1 Answers1

0

Sometimes selenium webdriver could not find elements, so better use javascript executor to click on desired button

Example:

js = (JavascriptExecutor) driver;
js.executeScript("$('#downloadcsv').click()");
Naseer Panhwer
  • 169
  • 1
  • 1
  • 10