def log_in(self, username, password): wait_until(lambda: check_if_elem_exist(self.inpUsename), timeout=120) send_text(self.inpUsename(), username) send_text(self.inpPassword(), password) self.btnLogIn().click() wait_until(lambda: check_if_elem_exist( lambda: self.driver.find_element_by_id("header-navigation")))
def add_tag(self, tag): expandButton = self.driver.find_element_by_id( "tagsdiv-download_tag").find_element_by_tag_name("button") if "false" in expandButton.get_attribute("aria-expanded"): expandButton.click() send_text(self.inpTag(), tag) self.btnAddTag().click()
def purchase_listing(self, payment, email, firstName, lastName, payPalEmail, payPalPassword): self.log.info("Execute method purchase_listing") time.sleep(5) wait_page_load(self.driver) wait_until(lambda: check_if_elem_exist( lambda: self.driver.find_element_by_css_selector( "div[class='edd_price_options edd_single_mode']"))) #formElement = self.driver.find_element_by_css_selector("form[id='edd_purchase_9273']") #edd_download_purchase_form edd_purchase_9273 formElement = self.driver.find_element_by_css_selector( "div[class='edd_price_options edd_single_mode']") purchases = formElement.find_elements_by_css_selector( "span[class='edd_price_option_name']") for purchase in purchases: if purchase.text == payment: purchase.find_element_by_xpath('..').click() time.sleep(1) self.log.screenshot("Selected payment={}".format(payment)) break self.aPurchase().click() time.sleep(5) self.aCheckout().click() send_text(self.inpEmail(), email, mode="update") send_text(self.inpFirstName(), firstName, mode="update") send_text(self.inpLastName(), lastName, mode="update") self.log.screenshot("Inserted email, firstname, lastname") self.btnFinalPurchase().click() wait_until(lambda: check_if_elem_exist(self.btnPayPal), 30) time.sleep(10) self.btnPayPal().click() wait_until(lambda: check_if_elem_exist( lambda: self.driver.find_element_by_id("payment_type_paypal")), timeout=60) self.driver.find_element_by_id("payment_type_paypal").click() self.driver.find_element_by_css_selector( "input[name='unified_login.x']").click() #paypal window is opened self.log.info("Add PayPal credentials") wait_until(lambda: check_if_elem_exist(self.inpPayPalEmail), timeout=60) send_text(self.inpPayPalEmail(), payPalEmail, mode="update") send_text(self.inpPayPalPass(), payPalPassword, mode="update") self.log.screenshot("Credentials for PayPal are entered") self.btnLogInPayPal().click() wait_until(lambda: check_if_elem_exist(lambda: self.driver. find_element_by_css_selector( "input[name='submit.x']"))) self.driver.find_element_by_css_selector( "input[name='submit.x']").click() wait_until(lambda: check_if_elem_exist( lambda: self.driver.find_element_by_xpath( "//h1[contains(text(),'{}')]".format( "Your purchase was successful")))) self.log.screenshot("Listing purchased")
def edit_info(self, firstName, lastName, email, mobile): self.aEditInfo().click() send_text(self.inpFirstName(), firstName, mode="update") send_text(self.inpLastName(), lastName, mode="update") send_text(self.inpEmail(), email, mode="update") send_text(self.inpMobile(), mobile, mode="update") self.log.screenshot() self.btnSubmit().click() time.sleep(3)
def sign_up(self, firstName, lastname, CEA, mobile): self.log.info("Execute method sign_up with parameters" " firstName={}, lastName={}, CEA={}, mobile={}".format( firstName, lastname, CEA, mobile)) send_text(self.inpFirstName(), firstName) send_text(self.inpLastName(), lastname) send_text(self.inpCEA(), CEA) send_text(self.inpMobileNumber(), mobile) self.log.screenshot("Entered info") self.btnNext().click() wait_until(lambda: not check_if_elem_exist(self.inpFirstName))
def log_in_social_media(self, email, password): """ Log in with facebook account :param email: Email :param password: Password """ self.log.info( "Execute method log_in_social_media with parameters email={}, password={}" .format(email, password)) self.cbxSocialID().click() time.sleep(1) self.btnLoginWithFacebook().click() wait_until(lambda: len(self.driver.window_handles) == 2, timeout=10) self.driver.switch_to.window(self.driver.window_handles[-1]) wait_until(lambda: check_if_elem_exist(self.inpFacebookEmail), timeout=30) self.log.info("Facebook login page opened") send_text(self.inpFacebookEmail(), email, mode="update") send_text(self.inpFacebookPass(), password, mode="update") self.btnLogInToFacebook().click() time.sleep(10) self.log.screenshot("Should be logged on facebook")
def set_basic_info(self, title, address, description, watermark="", publicAccess=True, mode="set"): """ Insert basic info for creating new tour :param title: Title of tour :type title: str :param address: Tour address :type address: str :param description: Tour description :type description: str :param watermark: Watermark :type watermark: str :param publicAccess: Choose radio button for public access :type publicAccess: bool :param mode: Possible values are set or update :type mode: str """ self.log.info( "Execute method set_basic_info with parameters title={}, address={}, description={}," " watermark={}, publicAccess={}, mode={}".format( title, address, description, watermark, publicAccess, mode)) if title: wait_until(lambda: check_if_elem_exist(self.inpTitle), timeout=30) send_text(self.inpTitle(), title, mode=mode) if address: send_text(self.inpAddress(), address, mode=mode) if watermark: send_text(self.inpWatermarkText(), watermark, mode="update") if publicAccess: self.rbtnPublicAccess("Yes").click() else: self.rbtnPublicAccess("No").click() if description: send_text(self.txtDescription(), description, mode=mode) self.log.screenshot("Data entered. Click on button submit") self.btnSubmit().click() wait = WebDriverWait(self.driver, 60) wait.until( expected_conditions.visibility_of_element_located( (By.CSS_SELECTOR, "div[class*='qq-upload-button']"))) self.log.info("Submit done")
def pay_pal(self, payPalEmail, payPalPassword, timeout): self.wait_paypal_opened(timeout) self.log.info("Add PayPal credentials") time.sleep(5) wait_until(lambda: check_if_elem_exist(self.btnLogInPayPal), timeout=timeout) self.btnLogInPayPal().click() wait_until(lambda: check_if_elem_exist(self.inpPayPalEmail), timeout=timeout) wait_until(lambda: check_if_elem_exist(self.btnContinuePayPal), timeout=timeout) send_text(self.inpPayPalEmail(), payPalEmail, mode="update") self.log.screenshot("Credentials for PayPal are entered") self.log.info("Click on continue") self.btnContinuePayPal().click() time.sleep(5) wait_until(lambda: check_if_elem_exist(self.inpPayPalPass), timeout=timeout) send_text(self.inpPayPalPass(), payPalPassword, mode="update") # wait_until(lambda: click_on_element_intercepted(self.btnContinuePayPal), timeout=timeout) # wait_until(lambda: check_if_elem_exist(self.btnPayNow), timeout=timeout) self.log.screenshot("Click on pay now") self.btnLogInPayPal2().click() self.log.screenshot("Paid")
def _add_info_data(self, title, detail, url, mode="set"): """ After info button is added to scene, insert information. :param mode: Possible values are set or update :type mode: str """ self.log.info("Execute method _add_info_data with parameters " "title={}, detail={}, url={}".format(title, detail, url)) send_text(self.inpInfoTitle(), title, mode) send_text(self.inpInfoDetail(), detail, mode) send_text(self.inpInfoUrl(), url, mode) self.log.screenshot("Information is added") self.btnSaveInfo().click() time.sleep(3)
def search_for(self, searchFor): send_text(self.inpSearch(), searchFor) self.btnSearch().click() wait_page_load(self.driver)
def set_model_url(self, url): send_text(self.inpModelURL(), url)
def set_description(self, desc): send_text(self.txtDescription(), desc)
def set_name(self, name): send_text(self.inpName(), name)
def set_excerpt(self, text): send_text(self.txtExcerpt(), text) self.log.screenshot()