Reputation: 13
I was doing an availability checker for some Amazon products, it was working but after I went for sometime I got back and I found this error. I don't know if I've missed something or editing something.
I hope the following information helps:
This is the error:
Exception has occurred: AttributeError 'WebDriver' object has no attribute 'link'
and this is my code:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import webbrowser
import time
import os
urls = [
"URL 1",
"URL 2"
]
PATH = "C:\Program Files (x86)\chromedriver.exe"
options = Options()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
driver = webdriver.Chrome(PATH, chrome_options=options)
def main():
# stuff
while True:
for i in range(0, len(urls)):
url = urls[i]
time.sleep(2)
print(url)
wait = WebDriverWait(driver, 10)
driver.link(url)
wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="availability"]/span')))
print(driver.title)
availablility = driver.find_element_by_xpath('//*[@id="availability"]/span')
print(availablility.text)
main()
I am using Python 3.7.9 64-bit in Visual Studio Code.
Upvotes: 1
Views: 1504
Reputation: 1732
There is no webdriver.link
. You probably meant to use webdriver.get
:
So just change driver.link(url)
into driver.get(url)
Upvotes: 1