Exemplo n.º 1
0
    def answered_by(self, the_actor: Actor) -> Union[str, List[str]]:
        """
        Investigates the page as viewed by the supplied |Actor| and gives
        their answer.

        Args:
            the_actor (Actor): The |Actor| who will answer the question.

        Returns:
            str: the text of the single option selected in a dropdown, or
                the first option selected in a multiselect field.
            List[str]: the text of all options selected in a multiselect
                field.
        """
        select = SelSelect(self.target.found_by(the_actor))

        if self.multi:
            return [e.text for e in select.all_selected_options()]
        else:
            return select.first_selected_option.text
from selenium.webdriver.support.ui import Select

driver = webdriver.Chrome()

driver.get("https://www.facebook.com/")
Action = ActionChains(driver)

Action.move_to_element(driver.find_element_by_id("birthday-help")).perform()

Action.move_to_element(
    driver.find_element_by_id("u_0_11")).click_and_hold().perform()
Action.move_to_element(
    driver.find_element_by_id("u_0_11")).context_click().perform()

select = Select(driver.find_element_by_id("month"))
d = select.all_selected_options()
print(d)
select.select_by_value("8")

#
# # Text Box
# Email = driver.find_element_by_id("email")
#
# Email.send_keys("*****@*****.**")
#
# Password = driver.find_element_by_id("pass")
#
# Password.send_keys("srihari")
#
# ForgotLink = driver.find_element_by_link_text("Forgotten account?")
# ForgotLink.click()