1

I try to automate the following site using selenium: https://www.infobyip.com/ipbulklookup.php

With the following code:

import os
import sys
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
import os, sys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
from fake_useragent import UserAgent

if __name__ == '__main__':
  SAVE_INTERVAL = 5
  WAIT = 3
  GROUPNUM = 25
  path = os.path.abspath(os.path.dirname(sys.argv[0]))  
  rowNum = 2 

  print(f"Checking chromedriver...")
  os.environ['WDM_LOG_LEVEL'] = '0' 
  ua = UserAgent()
  userAgent = ua.random
  options = Options()
  options.add_argument("start-maximized")
  options.add_experimental_option("prefs", {"profile.default_content_setting_values.notifications": 1})    
  options.add_experimental_option("excludeSwitches", ["enable-automation"])
  options.add_experimental_option('excludeSwitches', ['enable-logging'])
  options.add_experimental_option('useAutomationExtension', False)
  options.add_argument('--disable-blink-features=AutomationControlled')
  options.add_argument(f'user-agent={userAgent}')   
  srv=Service(ChromeDriverManager().install())
  driver = webdriver.Chrome (service=srv, options=options)    
  waitWebDriver = WebDriverWait (driver, 10)   
  link = f"https://www.infobyip.com/ipbulklookup.php" 
  driver.get (link)     
  try:
    waitWebDriver.until(EC.element_to_be_clickable( \
      (By.XPATH, "//input[@value='Accept']"))).click() 
  except:
    pass  
  waitWebDriver.until(EC.presence_of_element_located((By.XPATH,"//textarea"))) \
    .clear()
  waitWebDriver.until(EC.presence_of_element_located((By.XPATH,"//textarea"))) \
    .send_keys("www.2percentrealty.ca")
  time.sleep(WAIT)
  waitWebDriver.until(EC.element_to_be_clickable( \
    (By.XPATH, "//input[@value='Lookup']"))).click() 
  time.sleep(5000)

But unfortunately, I get the following error when running the program:

$ python SOcheckDomain.py
Checking chromedriver...
[WDM] -

[WDM] - ====== WebDriver manager ======
[WDM] - Current google-chrome version is 101.0.4951
[WDM] - Get LATEST driver version for 101.0.4951
[WDM] - Driver [C:\Users\WRSPOL\.wdm\drivers\chromedriver\win32\101.0.4951.41\chromedriver.exe] found in cache
Traceback (most recent call last):
  File "C:\DEV\Fiverr\ORDER\robalf\SOcheckDomain.py", line 49, in <module>
    waitWebDriver.until(EC.element_to_be_clickable( \
  File "C:\DEV\.venv\Normal\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
    self._execute(Command.CLICK_ELEMENT)
  File "C:\DEV\.venv\Normal\lib\site-packages\selenium\webdriver\remote\webelement.py", line 693, in 
_execute
    return self._parent.execute(command, params)
  File "C:\DEV\.venv\Normal\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 400, in execute
    self.error_handler.check_response(response)
  File "C:\DEV\.venv\Normal\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 236, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <input type="submit" value="Lookup" style="width: 120px"> is not clickable at point (810, 588). Other element would receive the click: <div class="noprint" style="width: 100%; text-align: center; height: 60px; position: fixed; left: 0; bottom: 0; background-color: white; box-shadow: 0 0 10px #888; 
z-index: 10001;">...</div>
  (Session info: chrome=101.0.4951.54)

Why is the button not clickable? And he is referring to another element in the error message (div class="print") - but this element is some completely different element on the site I would say.

Rapid1898
  • 895
  • 1
  • 10
  • 32
  • Yes thanks - this thread you linked was answering my question. When i scrolled down a little bit to the button with `driver.execute_script("window.scrollTo(0, 10000)") ` before it now seems to work fine When you write the solution as answer i would be happy to mark your answer as accepted. – Rapid1898 Jun 22 '22 at 11:27
  • i tried your code, it works for me, maybe try to update your libraries / chrome or meybe just reboot good luck and have a nice day ;) – Louis AT Jun 22 '22 at 11:10
  • Thanks for the answer - i think the problem is related to size of the screen - that means it is only working when its running on a big screen (so it works on your configuraton - but currently not on mine on a laptop). See also my answer above how i fixed the issue be scrolling a little bit down to the element. – Rapid1898 Jun 22 '22 at 11:30
  • thats interesting , it makes sense but i thats not the first thing that would cross my mind to be honest, i'm glad you found a solution – Louis AT Jun 22 '22 at 11:39

0 Answers0