def pytest_runtest_makereport(item): pytest_html = item.config.pluginmanager.getplugin('html') screen = SeleniumDriver(_driver) outcome = yield report = outcome.get_result() extra = getattr(report, 'extra', []) if report.when == 'call' or report.when == "setup": xfail = hasattr(report, 'wasxfail') if (report.skipped and xfail) or (report.failed and not xfail): # resultMessage # + "." + str(round(time.time() * 1000)) + ".png" file_name = str(round(time.time() * 1000)) + ".png" print("File Name :Link: " + file_name) # print("Path ::"+os.getcwd()) # srt1= os.getcwd().find() # print()os.getcwdb() # file_name = "screenshots"+os.sep+time.strftime("%Y%m%d%H%M%S",time.localtime(time.time()))+".png" screen.screenShot(file_name) # _capture_screenshot(file_name) if file_name: html = '<div><img src="%s" alt="screenshot" style="width:304px;height:228px;" ' \ 'onclick="window.open(this.src)" align="right"/></div>' % file_name extra.append(pytest_html.extras.html(html)) report.extra = extra
def setUp(self): self.instance = SeleniumDriver() self.driver = self.instance.driver_instance() self.driver.maximize_window() self.driver.get('https://www.ukr.net') self.driver.implicitly_wait(3) self.login_page = LoginPage(self.driver)
def __new__(cls, name, bases, attrs): _driver = get_driver() if name == 'Model': return super(BoxMetaClass, cls).__new__(cls, name, bases, attrs) # Also ensure initialization is only performed for subclasses of Model # (excluding Box class itself). parents = [b for b in bases if isinstance(b, BoxMetaClass)] if not parents: return super(BoxMetaClass, cls).__new__(cls, name, bases, attrs) # Get all attrs that are instances of Element class, and store them into ``mappings`` mappings = dict() for k, v in attrs.items(): if isinstance(v, Element): mappings[k] = v if isinstance(v, str): pass # Pass all necessary parameters for Element object. Ex: base_url, driver. for k, v in mappings.items(): v.base_url = 'http://giadinh.net.vn/' v.wdf = _driver v.driver = SeleniumDriver(v.wdf) attrs['driver'] = v.driver attrs.pop(k) # Pass all necessary parameters for Box class. Ex: base_url, driver. attrs['__mappings__'] = mappings attrs['__tabel__'] = name attrs['driver'] = _driver return super(BoxMetaClass, cls).__new__(cls, name, bases, attrs)
class TestALoginPage(unittest.TestCase): def setUp(self): self.instance = SeleniumDriver() self.driver = self.instance.driver_instance() self.driver.maximize_window() self.driver.get('https://www.ukr.net') self.driver.implicitly_wait(3) self.login_page = LoginPage(self.driver) def tearDown(self): self.driver.close() def test_login_invalid_email(self): self.login_page.verify_page_is_loaded( "UKR.NET: Всі новини України," " останні новини дня в Україні та Світі") self.login_page.login('{}"{::{|/', 'Python36') result = self.login_page.verify_error_is_appeared() assert result == True def test_login_valid(self): self.login_page.verify_page_is_loaded( "UKR.NET: Всі новини України," " останні новини дня в Україні та Світі") self.login_page.login('*****@*****.**', 'Python36') result = self.login_page.verify_login_success() assert result == True
def oneTimeSetUp(request, browser): conf = Config() url = conf.base_url wdf = WebDriverFactory(browser, url) driver = wdf.getWebDriverInstance() sd = SeleniumDriver(driver) sd.elementClick("(//button[text()='USA'])[3]", "xpath") log.info("Clicked USA as country") if request.cls is not None: request.cls.driver = driver yield driver log.info("Closing Browser") driver.quit() log.info("Browser Closed")
def __init__(self, driver): super().__init__(driver) self.driver = driver self.wait = SeleniumDriver(self.driver) self.navigator = NavigatePage(self.driver) self.fev = FindExistingValuePage(self.driver) self.supplier_id = [""]
def userPurchase(self, searchText='', email='', password=''): sd = SeleniumDriver(self.driver) self.enterSearchText('Blue Faded Shirt Sleeve T-shirt') self.clickSearchButton() self.clickColor() self.selectSize() self.clickAddToCart() sd.waitForElement("//a[@class='btn btn-default button button-medium']//span", "xpath", 5, 0.5) self.clickProceedToCheckout() self.clickProceedToCheckout1() self.enterEmail(email) self.enterPassword(password) self.clickSignIn() self.clickProceedToCheckout2() self.clickTerms() self.clickclickProceedToCheckout3() self.clickPayByBankWire() self.clickConfirmOrder()
def before_scenario(context, feature): cl.info("Automation Started") context.wdf = WebDriverFactory(browser=config.browser, url=config.url) context.driver = context.wdf.get_browser_instance() # All Page Objects initialized here context.selenium_driver = SeleniumDriver(context.driver) context.login = Login(context.driver) context.account = Account(context.driver)
class AutoPinner(BasePage): def __init__(self, driver): super().__init__(self) self.driver = driver self.sl = SeleniumDriver(driver) #Locators _search_bar = "//input[@data-test-id='search-box-input']" _save_button = "//div[@data-test-id='SaveButton']" _board_selection = "//div[@data-test-id='board-selection'][1]" _already_posted_img = "//div[@data-test-id='already-pinned']" _close_image_button = "//button[@aria-label='Close']" counter = 0 def inputSearch(self, search="Save the bees"): element = self.sl.getElement(self._search_bar, locatorType="xpath") element.send_keys(search) element.send_keys(Keys.ENTER) def clickImages(self): for i in range(1, 7): _images = "//*[@id='__PWS_ROOT__']/div[1]/div[3]/div/div/div/div[2]/div[1]/div/div/div/div[1]/div[" + str( i) + "]/div/div/div/div/div/div/div[1]/a" self.elementClick(_images, locatorType="xpath") time.sleep(2) self.clickSaveButton() time.sleep(1) alreadyHaveImage = self.elementPresenceCheck( self._already_posted_img, byType="xpath") if alreadyHaveImage is not True: self.boardSelection() time.sleep(2) self.inputSearch() else: self.elementClick(self._close_image_button, locatorType="xpath") self.inputSearch() def clickSaveButton(self): isSaveThere = self.elementPresenceCheck(self._save_button, byType="xpath") self.elementClick(self._save_button, locatorType="xpath") def boardSelection(self): self.elementClick(self._board_selection, locatorType="xpath") def PinningAutomation(self): self.inputSearch() time.sleep(2) self.clickImages() time.sleep(2)
class HomePageTests(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.hp = HomePage(self.driver) self.ts = TestStatus(self.driver) self.sd = SeleniumDriver(self.driver) @pytest.mark.run(order=1) def test_validload(self): result1 = self.hp.verifyHeaderPresent() assert result1 self.sd.screenShot(resultMessage='Header Present') time.sleep(10) self.hp.actionChainsMethodScrollBottomPage() result2 = self.hp.verifyFooterPresent() assert result2 self.sd.screenShot(resultMessage='Footer Present') self.ts.markFinal("test_validLoad", result1, "Header Successfully present") self.ts.markFinal("test_validLoad", result2, "Footer Successfully present") @pytest.mark.run(order=2) def test_verifyHeaderSearch(self): result3 = self.hp.verifyHeaderSearch() assert result3 self.sd.screenShot(resultMessage="Header Search Present") time.sleep(10) self.ts.markFinal("test_verifyHeaderSearch", result3, "Header Search Successfully present")
class RegisterCoursesTest(unittest.TestCase): @pytest.fixture(autouse=True) def classSetup(self, oneTimeSetUp): self.courses = RegisterCoursesPage(self.driver) self.ts = TStatus(self.driver) self.d = SeleniumDriver(self.driver) @pytest.mark.run(order=1) def test_invalidEnrollment(self): self.courses.openCousesPage() self.courses.enterCourseName("JavaScript") self.courses.selectCoureToEnroll("JavaScript for beginners") self.courses.startEnroll() self.courses.enterEmail("*****@*****.**") self.d.scrollPage(direction="down") self.courses.enrollCource(num="5457 0822 3591 3352", exp="12 / 19", cvv="123", postal="01234") result = self.courses.verifyEnrollFailed() self.ts.markFinal("test_invalidEnrollment", result, "Enrollment Failed verification")
class Login(BasePage): log = cl.customLogger(logging.DEBUG) def __init__(self, driver): super().__init__(self) self.driver = driver self.sl = SeleniumDriver(driver) self.actions = ActionChains(driver) # Locators _login_option = "//a[contains(text(), 'Already a member? Log in')]" _email_field = "email" _password_field = "password" _login_button = "//div[contains(text(), 'Log in')]//parent::button" _fb_button = "//*[@id='u_0_1']/div" _fb_frame = "//iframe[@title='fb:login_button Facebook Social Plugin']" def clickAlreadyAMemeber(self): self.elementClick(self._login_option, locatorType="xpath") def enterEmailField(self, email="*****@*****.**"): self.sendKeys(email, self._email_field) def enterPasswordField(self, password="******"): self.sendKeys(password, self._password_field) def clickLoginButton(self): self.elementClick(self._login_button, locatorType="xpath") def switchFBFrame(self): fbFrame = self.sl.getElement(self._fb_frame, locatorType="xpath") self.driver.switch_to.frame(fbFrame) def clickFBButton(self): self.elementClick(self._fb_button, locatorType="xpath") def loginMethod(self): self.clickAlreadyAMemeber() time.sleep(2) self.enterEmailField() time.sleep(2) self.enterPasswordField() time.sleep(2) self.clickLoginButton() time.sleep(1)
class TestBSendingEmail(unittest.TestCase): def setUp(self): self.instance = SeleniumDriver() self.driver = self.instance.driver_instance() self.driver.maximize_window() self.driver.get('https://mail.ukr.net') self.driver.implicitly_wait(3) self.login_page = LoginPage(self.driver) def tearDown(self): self.driver.close() def test_sending_email_to_mailinator(self): self.login_page.uk_login('*****@*****.**', 'Python36') self.login_page.sending_email( '*****@*****.**', 'testingtheme') #, 'testing content text message') result2 = self.login_page.uk_verify_email_sent() assert result2 == True
class TestCEmailinatorInbox(unittest.TestCase): def setUp(self): self.instance = SeleniumDriver() self.driver = self.instance.driver_instance() self.driver.maximize_window() self.driver.get('https://www.mailinator.com') self.driver.implicitly_wait(3) self.login_page = LoginPage(self.driver) def tearDown(self): self.driver.close() def test_inbox_sent_email(self): result = self.login_page.el_verify_inbox_email( '*****@*****.**') assert result == True def test_inbox_email_subject(self): result = self.login_page.el_verify_email_subject( '*****@*****.**') assert result == True
def class_setup(self, first_challenge_setup): self.seleniumDriver = SeleniumDriver(self.driver) self.homePage = HomePage(self.driver) self.loginPage = LoginPage(self.driver) self.dashboardPage = DashboardPage(self.driver) self.boardPage = BoardPage(self.driver) with open("/src/utils/data.json") as jsonfile: self.data = json.load(jsonfile) self.trelloCards = TrelloCards(self.data['auth']['api_key'], self.data['auth']['token']) self.trelloLists = TrelloLists(self.data['auth']['api_key'], self.data['auth']['token']) self.trelloBoards = TrelloBoards(self.data['auth']['api_key'], self.data['auth']['token']) self.trelloDriver = TrelloDriver(self.data['auth']['api_key'], self.data['auth']['token']) boardId = self.trelloBoards.create_new_board( self.data['third_challenge']['board_name'])['id'] challenge_list = self.trelloLists.create_list( self.data['third_challenge']['list_name'], boardId)
class ExplicitWaitType(): def __init__(self, driver): self.driver = driver self.seldr = SeleniumDriver(driver) def waitForElement(self, locator, locatorType="id", timeout=10, pollFrequency=0.5): element = None try: byType = self.seldr.getByType(locatorType) print("Waiting for maximum :: " + str(timeout) + ":: seconds for elemnt to be clickable") wait = WebDriverWait(self.driver, 10, pollFrequency=1, ignored_exceptions=[NoSuchElementException, ElementNotVisibleException, ElementNotSelectableException]) element = wait.until(EC.element_to_be_clickable(byType, locator)) print("Element appeared on the web page") except: print("Element not appeared on the web page") print_stack() return element
class AutoFollower(BasePage): def __init__(self, driver): super().__init__(self) self.driver = driver self.sl = SeleniumDriver(driver) #Locators _search_bar = "//input[@data-test-id='search-box-input']" _follow_button = "//button[@aria-label='Follow']" def inputSearch(self, search="Save the bees"): element = self.sl.getElement(self._search_bar, locatorType="xpath") element.send_keys(search) element.send_keys(Keys.ENTER) def followUser(self): for i in range(1, 50): _images = "//*[@id='__PWS_ROOT__']/div[1]/div[3]/div/div/div/div[2]/div[1]/div/div/div/div[1]/div[" + str( i) + "]/div/div/div/div/div/div/div[1]/a" self.elementClick(_images, locatorType="xpath") time.sleep(2) isUserFollowed = self.elementPresenceCheck(self._follow_button, byType="xpath") if isUserFollowed: self.elementClick(self._follow_button, locatorType="xpath") self.inputSearch() else: self.inputSearch() def FollowingAutomation(self): self.inputSearch() time.sleep(1) self.followUser()
class AddressPage(BasePage): log = cl.custom_logger(logging.DEBUG) def __init__(self, driver): super().__init__(driver) self.driver = driver self.util = Util() self.check = SeleniumDriver(self.driver) self.id_info = IdentifyingInformationPage(self.driver) # LOCATORS _summary_tab = "//a//span[contains(text(), 'ummary')]" # XPATH _identifying_info_tab = "//a//span[contains(text(), 'dentifying Information')]" # XPATH _contacts_tab = "//a//span[contains(text(), 'ontacts')]" # XPATH _location_tab = "//span[text() = 'ocation']" # XPATH _custom_tab = "//a//span[contains(text(), 'C')]" # XPATH _supplier_name = "VENDOR_NAME1" _description_field = "VNDR_ADDR_SCROL_DESCR$0" _sam_address_type = "VNDR_ADDR_SCROL_CCR_ADDR_TYPE$0" _add_new_address_btn = "$ICField2$new$0$$0" _country = "VENDOR_ADDR_COUNTRY$0" _address_1 = "VENDOR_ADDR_ADDRESS1$0" _address_2 = "VENDOR_ADDR_ADDRESS2$0" _address_3 = "VENDOR_ADDR_ADDRESS3$0" _address_4 = "VENDOR_ADDR_ADDRESS4$0" _number = "VENDOR_ADDR_NUM1$0" _door = "VENDOR_ADDR_NUM2$0" _city = "VENDOR_ADDR_CITY$0" _county = "VENDOR_ADDR_COUNTY$0" _state = "VENDOR_ADDR_STATE$0" _postal = "VENDOR_ADDR_POSTAL$0" _email_id = "VENDOR_ADDR_EMAILID$0" _override_address_box = "CLN_OVERRIDE_ADDRESS" _expand_alt_names_arrow = "//a[@class='PSHYPERLINK PTEXPAND_ARROW']" # XPATH _collapse_alt_names_arrow = "//a[@class='PSHYPERLINK PTCOLLAPSE_ARROW']" # XPATH _pmnt_alt_name_1 = "VENDOR_ADDR_NAME1$17$$0" _pmnt_alt_name_2 = "VENDOR_ADDR_NAME2$0" _wh_alt_name_1 = "VENDOR_ADDR_NAME1_WTHD$21$$0" _wh_alt_name_2 = "VENDOR_ADDR_NAME2_WTHD$0" _phone_type = "VENDOR_ADDR_PHN_PHONE_TYPE$0" _telephone_field = "VENDOR_ADDR_PHN_PHONE$0" _extension_field = "VENDOR_ADDR_PHN_EXTENSION$0" _add_new_row_phone = "VENDOR_ADDR_PHN$new$0$$0" _search_for_country = "VENDOR_ADDR_COUNTRY$prompt$0" _search_for_state = "VENDOR_ADDR_STATE$prompt$0" _effective_date = "VENDOR_ADDR_EFFDT$0" """ Get the elements """ def get_sam_address_type(self): return self.driver.find_element(By.ID, self._sam_address_type) def get_phone_type(self): return self.driver.find_element(By.ID, self._phone_type) """ Do something with the elements """ def click_location_tab(self): self.element_click(self._location_tab, "xpath") wait = WebDriverWait(self.driver, 10, poll_frequency=1) wait.until(ec.visibility_of_element_located((By.LINK_TEXT, "Payables"))) def click_contacts_tab(self): self.element_click(self._contacts_tab, "xpath") self.util.sleep(2, "the Contacts page to open.") def enter_description(self): sup_name = self.driver.find_element(By.ID, "VENDOR_NAME1").text self.sendkeys(sup_name, self._description_field) def select_sam_address_type(self, sam_type): sel = Select(self.get_sam_address_type()) sel.select_by_visible_text(sam_type) def enter_country_code(self, country_code): self.clear_element(self._country) self.sendkeys(country_code, self._country) self.sendkeys(Keys.TAB, self._country) self.util.sleep(1, "the country code to be recognized by the app.") def click_add_new_address_btn(self): self.element_click(self._add_new_address_btn) self.util.sleep(1) def enter_address_one(self): fake_data = Faker() fake_street_address = fake_data.street_address() self.sendkeys(fake_street_address, self._address_1) def enter_address_two(self): random_num = randint(1, 10) self.sendkeys("Bldg. " + str(random_num), self._address_2) def enter_address_three(self): self.sendkeys("N/A", self._address_3) def enter_city(self): fake_data = Faker() fake_city = fake_data.city() self.sendkeys(fake_city, self._city) def enter_postal_code(self): fake_data = Faker() fake_postal_code = fake_data.postalcode() self.sendkeys(fake_postal_code, self._postal) self.util.sleep(1, "the postal code to be recognized by the app.") def enter_random_state(self): self.sendkeys(str(choice(STATE_ABBR)), self._state) self.util.sleep(1, "the state to be recognized by the app.") def enter_email_id(self): fake_data = Faker() fake_email = fake_data.safe_email() self.sendkeys(fake_email, self._email_id) self.util.sleep(1, "the email to be recognized by the app.") def click_override_address_verification_chkbx(self): self.element_click(self._override_address_box) self.util.sleep(1, "the app recognizes the override.") def expand_alternate_names(self): self.element_click(self._expand_alt_names_arrow, "xpath") def collapse_alternate_names(self): self.element_click(self._collapse_alt_names_arrow, "xpath") def click_add_new_phone_btn(self): self.element_click(self._add_new_row_phone) def search_for_state(self): self.element_click(self._search_for_state) def enter_random_gb_county(self): self.sendkeys(str(choice(GBR_COUNTIES)), self._state) self.util.sleep(2, "the state to be recognized by the app.") def enter_pmnt_alt_name_1(self): fake_data = Faker() fake_name = fake_data.name() self.sendkeys(fake_name, self._pmnt_alt_name_1) def enter_pmnt_alt_name_2(self): fake_data = Faker() fake_name = fake_data.name() self.sendkeys(fake_name, self._pmnt_alt_name_2) def enter_withholding_alt_name_1(self): fake_data = Faker() fake_name = fake_data.name() self.sendkeys(fake_name, self._wh_alt_name_1) def enter_withholding_alt_name_2(self): fake_data = Faker() fake_name = fake_data.name() self.sendkeys(fake_name, self._wh_alt_name_2) """ THIS IS THE MODULE THAT IS CALLED BY THE TEST """ def enter_payment_withholding_alt_names(self): # expanded = self.check.element_presence_check(self._pmnt_alt_name_1) expanded = self.check.is_element_present(self._pmnt_alt_name_1) print(expanded) if expanded: self.enter_pmnt_alt_name_1() self.enter_pmnt_alt_name_2() self.enter_withholding_alt_name_1() self.enter_withholding_alt_name_2() else: self.expand_alternate_names() self.check.wait_for_element(self._pmnt_alt_name_1) self.enter_pmnt_alt_name_1() self.enter_pmnt_alt_name_2() self.enter_withholding_alt_name_1() self.enter_withholding_alt_name_2() def enter_business_phone(self): sel = Select(self.get_phone_type()) sel.select_by_visible_text("Business Phone") fake_data = Faker() fake_phone = fake_data.random_int(min=2000000, max=9999999) self.sendkeys("555" + str(fake_phone), self._telephone_field) self.element_click(self._add_new_row_phone) self.util.sleep(2, "the new phone row to be recognized by the app.") def enter_fax(self): sel = Select(self.get_phone_type()) sel.select_by_visible_text("FAX") fake_data = Faker() fake_phone = fake_data.random_int(min=2000000, max=9999999) self.sendkeys("555" + str(fake_phone), self._telephone_field) self.element_click(self._add_new_row_phone) self.util.sleep(2, "the new phone row to be recognized by the app.") def enter_trilogie_dm_fax(self): sel = Select(self.get_phone_type()) sel.select_by_visible_text("Trilogie DM Fax Number") fake_data = Faker() fake_phone = fake_data.random_int(min=2000000, max=9999999) self.sendkeys("555" + str(fake_phone), self._telephone_field) self.element_click(self._add_new_row_phone) self.util.sleep(2, "the new phone row to be recognized by the app.") def enter_all_phone_types(self): phone_type_list = ['Business Phone', 'FAX', 'Trilogie DM Fax Number'] for phone_type in phone_type_list: sel = Select(self.get_phone_type()) sel.select_by_visible_text(phone_type) fake_data = Faker() fake_phone = fake_data.random_int(min=2000000, max=9999999) self.sendkeys("555" + str(fake_phone), self._telephone_field) self.element_click(self._add_new_row_phone) self.util.sleep(2, "the new phone row to be recognized by the app.") def enter_domestic_master_vendor_address(self, sam_type): self.select_sam_address_type(sam_type) result = self.driver.find_element(By.ID, self._override_address_box).is_selected() if result: print('Checkbox already selected') else: self.driver.find_element(By.ID, self._override_address_box).click() print('Checkbox selected') self.enter_address_one() self.enter_address_two() self.enter_city() self.enter_postal_code() self.enter_random_state() def enter_corporate_info_address_domestic(self): self.enter_domestic_master_vendor_address("Corporate Info") self.enter_email_id() self.enter_business_phone() self.enter_fax() self.enter_trilogie_dm_fax() def enter_remit_address_domestic(self): self.enter_domestic_master_vendor_address("Remit") self.enter_email_id() self.enter_business_phone() self.enter_fax() self.enter_trilogie_dm_fax() def enter_po_address_domestic(self): self.enter_domestic_master_vendor_address("Trilogie PO Address") self.enter_email_id() self.enter_business_phone() self.enter_fax() self.enter_trilogie_dm_fax() def enter_foreign_master_vendor_address(self, sam_type, country_code): self.select_sam_address_type(sam_type) self.element_click(self._search_for_country) country = LookUpCountryWindow(self.driver) country.select_country(country_code) result = self.driver.find_element(By.ID, self._override_address_box).is_selected() if result: print('Checkbox already selected') else: self.driver.find_element(By.ID, self._override_address_box).click() print('Checkbox selected') self.enter_address_one() self.enter_address_two() self.enter_city() self.enter_postal_code() if country_code == "GBR": self.search_for_state() county = LookUpStateWindow(self.driver) county.select_county(str(choice(GBR_COUNTIES))) else: self.search_for_state() state = LookUpStateWindow(self.driver) state.select_random_state()
def __init__(self, driver): super().__init__(self) self.driver = driver self.sl = SeleniumDriver(driver) self.actions = ActionChains(driver)
def __init__(self, driver): super().__init__(self) self.driver = driver self.sd = SeleniumDriver(driver)
def classSetup(self, oneTimeSetUp): self.courses = RegisterCoursesPage(self.driver) self.ts = TStatus(self.driver) self.d = SeleniumDriver(self.driver)
def objectSetup(self, oneTimeSetUp): self.cp = CartPage(self.driver) self.lp = LoginPage(self.driver) self.ts = TestStatus(self.driver) self.nav = NavigationPage(self.driver) self.sd = SeleniumDriver(self.driver)
def __init__(self, driver): self.driver = driver self.seldr = SeleniumDriver(driver)
def objectSetup(self, oneTimeSetUp): self.courses = RegisterCoursesPage(self.driver) self.ts = TStatus(self.driver) self.d = SeleniumDriver(self.driver) self.nav = NavigationPage(self.driver)
def __init__(self,driver): SeleniumDriver.__init__(self,driver) self.driver=driver
class AutoCommenting(BasePage): def __init__(self, driver): super().__init__(self) self.driver = driver self.sl = SeleniumDriver(driver) #Locator _comment_tab_1 = "//a[@aria-selected='false']" _comment_tab_2 = "//button[@aria-label='Show more']" _comment_input = "//div[@role='textbox']" _comment_send_button = "//div[contains(text(), 'Done')]//parent::button" def inputSearch(self, search="Save the bees"): element = self.sl.getElement(self._search_bar, locatorType="xpath") element.send_keys(search) element.send_keys(Keys.ENTER) def pressCommentTab(self): commentTab1 = self.elementPresenceCheck(self._comment_tab_1, byType="xpath") commentTab2 = self.elementPresenceCheck(self._comment_tab_2, byType="xpath") if commentTab1: self.elementClick(self._comment_tab_1, locatorType="xpath") elif commentTab2: self.elementClick(self._comment_tab_2, locatorType="xpath") else: self.inputSearch() def inputComment(self, comment="Awesome picture! "): self.sendKeys(comment, self._comment_input, locatorType="xpath") def sendComment(self): self.elementClick(self._comment_send_button, locatorType="xpath") def imageCommenting(self, username="******"): for i in range(1, 11): _images = "//*[@id='__PWS_ROOT__']/div[1]/div[3]/div/div/div/div[2]/div[1]/div/div/div/div[1]/div[" + str( i) + "]/div/div/div/div/div/div/div[1]/a" self.elementClick(_images, locatorType="xpath") time.sleep(2) self.pressCommentTab() time.sleep(1) userMessage = "//img[@alt='" + str(username) + "']" didIMessage = self.elementPresenceCheck(username, byType="xpath") if didIMessage is not True: self.inputComment() time.sleep(1) self.sendComment() time.sleep(1) self.inputSearch() time.sleep(2) else: self.inputSearch() def CommentingAutomation(self): self.inputSearch() self.imageCommenting()
def __init__(self, driver): SeleniumDriver.__init__(self, driver) self.resultList = []
def __init__(self, driver): super().__init__(driver) self.driver = driver self.util = Util() self.check = SeleniumDriver(self.driver) self.id_info = IdentifyingInformationPage(self.driver)
def __init__(self, driver): #super().__init__(driver) SeleniumDriver.__init__(self, driver) self.driver = driver
def clickCustomersLink(self): SeleniumDriver(self.driver).elementClick(locator.customerLink) return CustomerPage(self.driver)