def test_add_browser(): conf = SeleniumConfiguration().add_browser( IosDeviceInfo("iPhone X", "portrait")) assert conf.browsers_info == [ IosDeviceInfo(IosDeviceName.iPhone_X, ScreenOrientation.PORTRAIT) ] conf = SeleniumConfiguration().add_browser( ChromeEmulationInfo("iPhone 4", "portrait")) assert conf.browsers_info == [ ChromeEmulationInfo(DeviceName.iPhone_4, ScreenOrientation.PORTRAIT) ] conf = (SeleniumConfiguration().set_baseline_env_name( "Default baseline").add_browser( 400, 600, BrowserType.EDGE_CHROMIUM, "Baseline").add_browser(500, 600, BrowserType.SAFARI).add_browser( 500, 600, BrowserType.FIREFOX).add_browser( DesktopBrowserInfo(400, 600, BrowserType.EDGE_CHROMIUM))) assert conf.browsers_info == [ DesktopBrowserInfo(400, 600, BrowserType.EDGE_CHROMIUM, "Baseline"), DesktopBrowserInfo(500, 600, BrowserType.SAFARI, "Default baseline"), DesktopBrowserInfo(500, 600, BrowserType.FIREFOX, "Default baseline"), DesktopBrowserInfo(400, 600, BrowserType.EDGE_CHROMIUM), ]
def test_desktop_browser_info(): dri = DesktopBrowserInfo(500, 600) assert dri.width == 500 assert dri.height == 600 assert dri.browser_type == BrowserType.CHROME assert dri.baseline_env_name is None dri = DesktopBrowserInfo(500, 600, BrowserType.SAFARI) assert dri.width == 500 assert dri.height == 600 assert dri.browser_type == BrowserType.SAFARI assert dri.baseline_env_name is None dri = DesktopBrowserInfo(500, 700, BrowserType.SAFARI, "base env") assert dri.width == 500 assert dri.height == 700 assert dri.browser_type == BrowserType.SAFARI assert dri.baseline_env_name == "base env"
def test_add_browsers(): browsers = [ IosDeviceInfo("iPhone X", "portrait"), IosDeviceInfo("iPhone 11", "landscape"), DesktopBrowserInfo(400, 600, BrowserType.EDGE_CHROMIUM), ] conf = SeleniumConfiguration().add_browsers(*browsers) assert conf.browsers_info == browsers conf = SeleniumConfiguration().add_browsers(browsers) assert conf.browsers_info == browsers
def browsers_info(self): # type: () -> List[RenderBrowserInfo] if self._browsers_info: return self._browsers_info if self.viewport_size: browser_info = DesktopBrowserInfo( width=self.viewport_size["width"], height=self.viewport_size["height"], browser_type=BrowserType.CHROME, baseline_env_name=self.baseline_env_name, ) return [browser_info] return []
def add_browser(self, *args): # noqa if isinstance(args[0], IRenderBrowserInfo): self._browsers_info.append(args[0]) elif (isinstance(args[0], int) and isinstance(args[1], int) and isinstance(args[2], BrowserType)): if len(args) == 4: baseline_env_name = args[3] else: baseline_env_name = self.baseline_env_name self._browsers_info.append( DesktopBrowserInfo(args[0], args[1], args[2], baseline_env_name)) else: raise TypeError( "Unsupported parameter: \n\ttype: {} \n\tvalue: {}".format( type(args), args)) return self
def __new__(cls, name, width): return super(DummyTest, cls).__new__(cls, name, DesktopBrowserInfo(width, 0))