__author__ = '<NAME>'
__email__ = "<EMAIL>"

from locators import DigitalOceanLocators
from selenium.webdriver.support.ui import Select


class DigitalOcean(object):

    def __init__(self, driver):
        self.driver = driver

    def type_access_key(self, val):
        element = self.driver.find_element(*DigitalOceanLocators.Ec2Locators.ACCESS_KEY_INPUT)
        element.clear()
        element.send_keys(val)

    def type_secret_key(self,val):
        element = self.driver.find_element(*DigitalOceanLocators.Ec2Locators.SECRET_KEY_INPUT)
        element.clear()
        element.send_keys(val)

    def click_next_btn(self):
        element = self.driver.find_element(*DigitalOceanLocators.Ec2Locators.NEXT_BTN)
        element.click()

    def get_availability_zone_list(self):
        element = self.driver.find_element(*DigitalOceanLocators.Ec2Locators.AVAILABILITY_ZONE)
        return element.text

    def select_zone(self, zone):
        element = self.driver.find_element(*DigitalOceanLocators.Ec2Locators.ZONE_SELECT)
        select = Select(element)
        select.select_by_visible_text(zone)

    def click_vpc_radio_btn(self):
        element = self.driver.find_element(*DigitalOceanLocators.Ec2Locators.VPC_RADIO_BTN)
        element.click()

    def click_subnet_radio_btn(self):
        element = self.driver.find_element(*DigitalOceanLocators.Ec2Locators.SUBNET_RADIO_BTN)
        element.click()

    def click_security_grp_std_btn(self):
        element = self.driver.find_element(*DigitalOceanLocators.Ec2Locators.STD_RADIO_BTN)
        element.click()

    def click_security_grp_custom_btn(self):
        element = self.driver.find_element(*DigitalOceanLocators.Ec2Locators.CUSTOM_RADIO_BTN)
        element.click()

    def click_set_instance_option_btn(self):
        element = self.driver.find_element(*DigitalOceanLocators.Ec2Locators.SET_INSTANCE_OPTION_BTN)
        element.click()

    def click_slide_bar_3(self):
        element = self.driver.find_element(*DigitalOceanLocators.Ec2Locators.SLIDE_BAR_CLICK_3)
        element.click()

    def type_host_name(self, host_name):
        element = self.driver.find_element(*DigitalOceanLocators.Ec2Locators.HOST_NAME_INPUT)
        element.clear()
        element.send_keys(host_name)

    def type_host_desc(self, host_desc):
        element = self.driver.find_element(*DigitalOceanLocators.Ec2Locators.HOST_DESC_INPUT)
        element.clear()
        element.send_keys(host_desc)

    def select_host_instance_type(self, instance_type):
        element = self.driver.find_element(*DigitalOceanLocators.Ec2Locators.HOST_INSTANCE_TYPE_SELECT)
        select = Select(element)
        select.select_by_visible_text(instance_type)

    def type_host_mem_size(self, host_mem_size):
        element = self.driver.find_element(*DigitalOceanLocators.Ec2Locators.HOST_MEM_SIZE_INPUT)
        element.clear()
        element.send_keys(host_mem_size)

    def click_create_btn(self):
        element = self.driver.find_element(*DigitalOceanLocators.Ec2Locators.HOST_CREATE_BTN)
        element.click()





