Entry point for creating an instance.
(
cls,
config: Config = None,
*,
user_data_dir: PathLike = None,
headless: bool = False,
incognito: bool = False,
guest: bool = False,
browser_executable_path: PathLike = None,
browser_args: List[str] = None,
sandbox: bool = True,
host: str = None,
port: int = None,
**kwargs,
)
| 108 | |
| 109 | @classmethod |
| 110 | async def create( |
| 111 | cls, |
| 112 | config: Config = None, |
| 113 | *, |
| 114 | user_data_dir: PathLike = None, |
| 115 | headless: bool = False, |
| 116 | incognito: bool = False, |
| 117 | guest: bool = False, |
| 118 | browser_executable_path: PathLike = None, |
| 119 | browser_args: List[str] = None, |
| 120 | sandbox: bool = True, |
| 121 | host: str = None, |
| 122 | port: int = None, |
| 123 | **kwargs, |
| 124 | ) -> Browser: |
| 125 | """Entry point for creating an instance.""" |
| 126 | if not config: |
| 127 | config = Config( |
| 128 | user_data_dir=user_data_dir, |
| 129 | headless=headless, |
| 130 | incognito=incognito, |
| 131 | guest=guest, |
| 132 | browser_executable_path=browser_executable_path, |
| 133 | browser_args=browser_args or [], |
| 134 | sandbox=sandbox, |
| 135 | host=host, |
| 136 | port=port, |
| 137 | **kwargs, |
| 138 | ) |
| 139 | try: |
| 140 | instance = cls(config) |
| 141 | await instance.start() |
| 142 | except Exception: |
| 143 | time.sleep(0.15) |
| 144 | instance = cls(config) |
| 145 | await instance.start() |
| 146 | return instance |
| 147 | |
| 148 | def __init__(self, config: Config, **kwargs): |
| 149 | """ |
no test coverage detected