Reputation: 517
I am trying to run a python script which will keep on clicking the load more button till it disappear. the code which I am trying is as shown below:
import csv
import time
import re
from bs4 import BeautifulSoup
from selenium.common.exceptions import NoSuchElementException
from selenium import webdriver
import requests
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
page=requests.get('https://www.killerfeatures.com/mobile/brands').content
soup1=BeautifulSoup(page,"html5lib")
brndsbox=soup1.find_all("div",attrs={"class":"brndsbox"})
count=0
brand_link=[]
for each in brndsbox:
x= each.find("span")
j=str(x).split('=')[5].split('"><')[0].replace('"',"")
brand_link+=["https://www.killerfeatures.com"+j]
chromedriver=r"D:\MOBILE_JUNE_22_2017\old_files_\price raja mobile\working\chromedriver.exe"
driver=webdriver.Chrome(chromedriver)
for url in brand_link:
print url
driver.get(url)
track_count=0
while True:
try:
element = WebDriverWait(driver, 20).until( EC.presence_of_element_located((By.ID, "loadMoreRecords")) )
element.click()
print "click", track_count
time.sleep(5)
track_count+=1
except NoSuchElementException:
break
print "complete"
Problem here is it is showing error as selenium.common.exceptions.WebDriverException: Message: unknown error: Element is not clickable at point (636, 583)
any idea why it is happening. I have already used a explicit wait till element is visible. after that also I am getting error. Thanks in advance!
Upvotes: 0
Views: 223
Reputation: 17593
Use JavascriptExecutor . It will operate directly through JS. It should work. I am giving an example to click any element using JavascriptExecutor
Code should be like below :-
element=driver.find_element_by_xpath('YOURXPATH')
driver.execute_script("arguments[0].click();", element)
Note :- change the locator in above code as per need
Hope it will help you :)
Upvotes: 1