Python selenium using bot to move scroll

21 Views Asked by At

I am trying to create a shopping bot on trendyol.com. I was good at all things until I came the scrolling part.

You can click this link text

and you can see "Marka" part. Under the "Marka" part there are brands. My main aim is taking brands as text and write in cmd to show the brands for user. Then user will choose just one brand and bot is gonna click.

THE PROBLEM is I cant correctly take brands elements and cant clicking because of the element tags I guess

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
import time
import pyautogui

options = webdriver.ChromeOptions()                
options.add_experimental_option("detach", True)    


service = Service("./chromedriver.exe")      

driver = webdriver.Chrome(options=options,service=service) 


class Trendyol():
    def __init__(self):
        self.link = "https://www.trendyol.com/"
        
    def entering_site(self):
        driver.get(self.link)
        time.sleep(10)
        pyautogui.press("F5")                      # !!!!! Ekrana gelen popup'ı geçmek için F5 e bastırdım
        
        print("*********************ACCESSING TO SITE IS SUCCESSFUL")

    def searching_product(self):
        time.sleep(10)     
        search = driver.find_element(By.XPATH,'//*[@id="sfx-discovery-search-suggestions"]/div/div[1]/input')

        search.send_keys("cep telefonu")

        search.send_keys(Keys.ENTER)
        
        print("*********************SEARCHING PRODUCT IS SUCCESSFUL")
        
        pyautogui.press("F5")
        
        time.sleep(4)
        
        # CEP TELEFONU SAYFASINA GİRİLDİ

    def brands_choosing(self):
        pass


start = Trendyol()
start.entering_site()
start.searching_product()
start.brands_choosing()

You can see "Marka" part. Under the "Marka" part there are brands. My main aim is taking brands as text and write in cmd to show the brands for user. Then user will choose just one brand and bot is gonna click.

THE PROBLEM is I cant correctly take brands elements and cant clicking because of the element tags I guess.

0

There are 0 best solutions below