Dokümantasyon olarak aşağıdaki siteyi kullanıyoruz:

https://selenium-python.readthedocs.io/

Kurulum için:

pip install selenium

Sürücü yüklemeleri için:

Chromehttps://sites.google.com/a/chromium.org/chromedriver/downloads
Edgehttps://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Firefoxhttps://github.com/mozilla/geckodriver/releases
Safarihttps://webkit.org/blog/6900/webdriver-support-in-safari-10/

Videodaki kodlar:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome(r'D:\Softic Yazilim\Kurslar\YouTube\Selenium\chromedriver.exe')

driver.get('https://www.softicyazilim.com')

blog_sayfasina_girelim = driver.find_element_by_link_text("BLOG")
blog_sayfasina_girelim.click()

# yazilar = driver.find_elements_by_class_name("blog-title")
yazilar = driver.find_elements_by_class_name("entry-title")
for yazi in yazilar:
    print(yazi.text)

son_yazi = driver.find_element_by_link_text(yazilar[0].text)
son_yazi.click()

try:
    mesaj = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, "comment"))
    )
    mesaj.send_keys("Süper havalı içerikler için teşekkürler!!!")

    yazar = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, "author"))
    )
    yazar.send_keys("osman")

    email = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.NAME, "email"))
    )
    email.send_keys("osman@softicyazilim.com")

    onay = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.CSS_SELECTOR, "#wp-comment-cookies-consent"))
    )
    onay.click()

    dugme = WebDriverWait(driver, 10).until(
        # EC.presence_of_element_located((By.XPATH, "/html/body/div[1]/div/div/div[1]/div/div[2]/div/div/form/p[7]/input[1]"))
        EC.presence_of_element_located(
            (By.XPATH, "/html/body/div[1]/div/div/div/div/div/form/p[7]/input[1]"))
    )
    dugme.click()

except:
    print("hata oluştu")

2 thoughts on “Python Selenium Dersleri 3”

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir