Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
3.1 kB
1
Indexable
Never
import time
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from .base_page import BasePage
from selenium.webdriver.support import expected_conditions as EC


class CareersPage(BasePage):
    LOCATIONS_SECTION = (By.CSS_SELECTOR, "[data-id='8ab30be']")
    TEAMS_SECTION = (By.CSS_SELECTOR, "[data-id='b6c45b2']")
    LIFE_AT_INSIDER_SECTION = (By.CSS_SELECTOR, "[data-id='a8e7b90']")
    SEE_ALL_TEAMS_LINK = (By.XPATH, "//a[text()='See all teams']")
    JOB_ITEM = (By.LINK_TEXT, "Quality Assurance")
    JOB_TITLE = (By.CSS_SELECTOR, ".job-title")
    SHOW_POSITIONS = (By.LINK_TEXT, "See all QA jobs")
    LOCATION_DROPDOWN_BUTTON = (By.CSS_SELECTOR, ".select2-selection--single")  # Dropdown'u açan görünür element
    ISTANBUL_TURKEY_OPTION = (By.XPATH, "//li[contains(text(), 'Istanbul, Turkey')]")  # Seçenek

    def verify_sections(self):
        locations_present = self.is_visible(self.LOCATIONS_SECTION)
        print("Locations section is present:", locations_present)

        teams_present = self.is_visible(self.TEAMS_SECTION)
        print("Teams section is present:", teams_present)

        life_at_insider_present = self.is_visible(self.LIFE_AT_INSIDER_SECTION)
        print("Life at Insider section is present:", life_at_insider_present)

        return locations_present and teams_present and life_at_insider_present

    def click_see_all_teams(self):
        teams_section = self.wait.until(EC.visibility_of_element_located(self.TEAMS_SECTION))
        see_all_teams_link = teams_section.find_element(*self.SEE_ALL_TEAMS_LINK)
        actions = ActionChains(self.driver)
        actions.move_to_element(see_all_teams_link).perform()
        see_all_teams_link.click()

    def click_qa_page(self):
        job_to_click = self.wait.until(EC.visibility_of_element_located(self.JOB_ITEM))
        actions = ActionChains(self.driver)
        actions.move_to_element(job_to_click).perform()
        job_to_click.click()
        print("Clicked Quality Assurance page.")

    def click_see_all_qa_jobs(self):
        qa_job_click = self.wait.until(EC.visibility_of_element_located(self.SHOW_POSITIONS))
        qa_job_click.click()

    def select_istanbul_turkey(self):
        # Sayfayı biraz aşağı kaydır
        self.driver.execute_script("window.scrollBy(0, 500);")
        print("Page scrolled down by 500 pixels.")

        # Sayfanın yüklenmesi ve dropdown'ın içeriğinin dolması için 10 saniye bekle
        print("Waiting for 10 seconds to allow dropdown content to load.")
        time.sleep(10)

        # Dropdown'u açmak için görünür elemente tıklat
        dropdown_button = self.wait.until(EC.element_to_be_clickable(self.LOCATION_DROPDOWN_BUTTON))
        dropdown_button.click()

        # Istanbul, Turkey seçeneğinin görünmesini bekle ve tıklat
        istanbul_option = self.wait.until(EC.element_to_be_clickable(self.ISTANBUL_TURKEY_OPTION))
        istanbul_option.click()

        print("Selected 'Istanbul, Turkey' from the location dropdown.")
        time.sleep(10)
Leave a Comment