def __init__(self, config): methods = [{ 'id': 'switch', 'min_pause': 0, 'response': { 'success': { 'name': 'Success', 'unit': 'boolean', }, 'target': { 'name': 'Current status', 'unit': 'onoff', } }, 'payload': { 'state': { 'type': 'select', 'options': [ { 'value': 'on', 'label': 'On' }, { 'value': 'off', 'label': 'Off' }, { 'value': 'toggle', 'label': 'Toggle' }, ], } } }, { 'id': 'status', 'min_pause': 0, 'response': { 'status': { 'name': 'Status', 'unit': 'onoff', } } }, { 'id': 'close', 'min_pause': 0, 'response': { 'success': { 'name': 'Success', 'unit': 'boolean', } } }] self.pins = {} self.config = config self.relays = {} Driver.__init__(self, name='MCP23017', methods=methods)
def browser(): factory = Driver() browser = factory.GetDriver() if browser is not None: print("New driver instance created!") else: raise WebDriverException("Never created!") yield browser browser.quit()
def __init__(self, config): methods = [{ 'id': 'read', 'min_pause': 2, 'response': { 'range': { 'name': 'Range', 'unit': 'cm', } } }] Driver.__init__(self, name='HCSR04', methods=methods)
def __init__(self, config): methods = [ { 'id': 'read', 'min_pause': 2, 'response': { 'light': { 'id': 'light', 'name': 'Light', 'unit': 'lux', } } } ] Driver.__init__(self, name='TSL2561', methods=methods)
def test2(): desired = DesiredCapabilities("Android", "Android", "Xiaomi", "9", "com.android.chrome", "com.google.android.apps.chrome.Main") driver = Driver("http://127.0.0.1:4723/wd/hub", desired.__dict__) chrome_test = Chrome(driver) chrome_test.run_app()
def __init__(self, config): methods = [{ 'id': 'read', 'min_pause': 2, 'response': { 'pressure': { 'name': 'Pressure', 'unit': 'hPa', }, 'temperature': { 'name': 'Temperature', 'unit': 'celsius', } } }] Driver.__init__(self, name='BMP280', methods=methods)
def __init__(self, config): methods = [{ 'id': 'read', 'min_pause': 2, 'response': { 'humidity': { 'name': 'Humidity', 'unit': 'percent', }, 'temperature': { 'name': 'Temperature', 'unit': 'celsius', } } }] Driver.__init__(self, name='AM2320', methods=methods)
def __init__(self, config, settings): methods = [{ 'id': 'read', 'min_pause': 0, 'response': { 'output': { 'name': 'Output', } } }] self.cs = settings['cs'] self.miso = settings['miso'] self.mosi = settings['mosi'] self.clk = settings['clk'] self.relays = {item['id']: item for item in config['relays']} Driver.__init__(self, name='MCP3008', methods=methods)
def test1(): desired = DesiredCapabilities("Android", "Android", "Xiaomi", "9.0", "com.mbacallado.thirdexampleandroid", ".activities.MainActivity") driver = Driver("http://127.0.0.1:4723/wd/hub", desired.__dict__) mir_app_test = MirApp(driver) mir_app_test.run_app("Tenerife", "Buenavista del Norte", "Mirador Altos de Baracán")
logger = logging.getLogger(__name__) class Base(BasePage): def __init__(self, driver: Driver): self.driver = driver super().__init__(driver=driver) def run_process(self): try: self.driver.get(self.url) sleep(5) if 'sign_in' in self.driver.current_url: LoginPage(self.driver).sign_in() sleep(30) main = MainPage(self.driver) main.email_popup() main.upload_design() except Exception as err: now = datetime.now().strftime('%Y-%m-%d_%H-%M-%S') self.driver.save_screenshot(f'debug/{now}.png') logger.error(err) print(err) if __name__ == "__main__": driver = Driver.chrome() base = Base(driver) base.run_process()