Created
June 22, 2015 10:20
-
-
Save Khrol/61d8e2fae200836514cf to your computer and use it in GitHub Desktop.
https://github.com/wgnet/webium/issues/6 workaround
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from webium import settings | |
from webium import driver as webium_driver_hack | |
from webium import BasePage | |
from selenium.webdriver.common.by import By | |
from webium import Find, Finds | |
from selenium.webdriver.remote.webelement import WebElement | |
from selenium import webdriver | |
import time | |
class DropList(WebElement): | |
button = Find(by=By.XPATH, value=".//*[@type='button']") | |
drop_list = Finds(by=By.XPATH, value=".//li/a") | |
def set_pass(self, value): | |
self.button.click() | |
self.drop_list[value - 1].click() | |
class BasePageMy(BasePage): | |
settings.default_search_type = By.XPATH | |
def __init__(self, url): | |
BasePage.__init__(self, Driver.get(), url) | |
def get_title(self): | |
return Driver.get().title | |
class Search(BasePageMy): | |
""" Страница 'Поиск' """ | |
passanger_aaa = Find(ui_type=DropList, value=".//*[@class='btn-group bootstrap-select form-control pass-count-select pass-type-select-base-category-count']") | |
show_children = Find(value=".//*[@id='showChildCountersBut']") | |
info_flight_list = {} | |
page_url = "http://tst.sirena-travel.ru/oxygen" | |
def __init__(self): | |
BasePageMy.__init__(self, self.page_url) | |
self.open() | |
print (u"Открылась страница %s" % self.get_title()) | |
def pax(self, AAA=2): | |
""" Функция для задания количества пассажиров """ | |
self.show_children.click() | |
if AAA != 1: | |
self.passanger_aaa.set_pass(AAA) | |
class Driver(object): | |
_instance = None | |
@classmethod | |
def get(cls): | |
if not getattr(cls, '_instance'): | |
cls._instance = webdriver.Firefox() | |
webium_driver_hack._driver_instance = cls._instance | |
return cls._instance | |
@classmethod | |
def close(cls): | |
if getattr(cls, '_instance'): | |
cls.get().close() | |
cls._instance = None | |
if __name__ == "__main__": | |
SearchPage = Search() | |
time.sleep(2) | |
SearchPage.pax(AAA=2) | |
time.sleep(5) | |
Driver.get().close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment