-
-
Notifications
You must be signed in to change notification settings - Fork 83
Open
Description
with selenium_driverless fb2339a
i can create a new tab with
driver_window = await driver.switch_to.new_window('tab')but then i cannot switch to the new tab with
await driver.switch_to.window(driver_window)test_selenium_driverless_switch_to_window.py
#!/usr/bin/env python3
from selenium_driverless import webdriver
from selenium_driverless.types.by import By
import asyncio
async def main():
options = webdriver.ChromeOptions()
async with webdriver.Chrome(options=options) as driver:
await driver.get('data:text/plain,tab 1', wait_load=True)
# create a new tab ("window")
driver_window = await driver.switch_to.new_window('tab')
await driver_window.get('data:text/plain,tab 2', wait_load=True)
print(f"driver_window {driver_window}")
# FIXME driver.switch_to.window(driver_window) has no effect
# expected: the browser should show the new tab (driver_window) (tab 2)
window_a = await driver.current_target
await driver.switch_to.window(driver_window)
window_b = await driver.current_target
# assert window_a != window_b
if window_a == window_b:
print("FIXME window_a == window_b")
else:
print("ok")
await asyncio.sleep(10)
asyncio.run(main())sources
selenium_driverless/types/context.py
from selenium_driverless.sync.switch_to import SwitchTo as SyncSwitchTo
class Context:
# ...
async def start_session(self):
# ...
if not self._started:
# ...
if self._loop:
self._switch_to = await SyncSwitchTo(context=self, loop=self._loop, context_id=self._context_id)
else:
self._switch_to = await SwitchTo(context=self, loop=self._loop, context_id=self._context_id)
@property
def switch_to(self) -> SwitchTo:
return self._switch_toselenium_driverless/scripts/switch_to.py
class SwitchTo:
# ...
async def window(self, window_id: str or TargetInfo, activate: bool = False, focus:bool=True) -> Target:
return await self.target(window_id, activate=activate, focus=focus)Metadata
Metadata
Assignees
Labels
No labels