I am running this script that fetches some content after finding an id, which will be populated by AJAX call, it should go to the second URL. After going to the second URL it doesn't find any content with the same id.
Code snippet is here:
from selenium import webdriver
from selenium.webdriver.remote.webelement import WebElement
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
import json
from selenium.webdriver.support import expected_conditions as EC
path_to_chromedriver = 'D:\Mangilal\Downloads\chromedriver_win32\chromedriver.exe' #Change path
as needed.
browser = webdriver.Chrome(executable_path=path_to_chromedriver)
#Sample list of URLs.
lists_of_url = ['http://facebook.com', 'http://twitter.com',
'http://google.com', 'http://youtube.com',
'http://linkedin.com', 'http://wordpress.org',
'http://instagram.com', 'http://pinterest.com',
'http://wikipedia.org', 'http://wordpress.com',
'http://slideshare.net', 'http://e-recht24.de',
'http://washingtonpost.com', 'http://etsy.com',
'http://eventbrite.com', 'http://archive.org',
'http://cpanel.net', 'http://miibeian.gov.cn',
'http://sourceforge.net', 'http://telegraph.co.uk',
'http://ameblo.jp', 'http://amazon.co.uk',
'http://ebay.com', 'http://fc2.com',
'http://free.fr', 'http://bing.com']
for i in range(10):
url = 'https://www.shareaholic.com/sharecounter?url=' + lists_of_url[i]
browser.get(url)
element = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.XPATH, '//*[@id="container"]/div[1]/div[2]/div[3]/div/div/h1/span')))
str = ''
#Finding element here.
count = browser.find_element_by_xpath('//*[@id="container"]/div[1]/div[2]/div[3]/div/div/h1/span')
str = count.get_attribute('innerHTML')
print(str)
Output of this is shown in the image, which fetches content for the first URL after that null value:

'http://wikipedia.org', 'http://wordpress.com', ',occur the same way in your code? There is a quoting error there