Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def test_chained_actions(session):
if isinstance(session.browser, Firefox) and isinstance(
session.driver.connection, RemoteConnection
):
raise pytest.skip("remote firefox actions do not work")
async def check(actions, expected):
await session.perform_actions(actions)
output = await session.get_element("#output")
assert expected == await output.get_text()
await session.get("/actions/")
output = await session.wait_for_element(5, "#output")
assert "" == await output.get_text()
await session.get("/actions/")
output = await session.wait_for_element(5, "#output")
import os
from urllib.parse import urlparse, parse_qsl, urlunparse
import attr
import shutil
import sys
from arsenic.browsers import Firefox
from arsenic.services import Geckodriver, Remote
BROWSERS = {
'firefox': Firefox,
}
@attr.s
class ServiceContext:
driver = attr.ib()
browser = attr.ib()
name = attr.ib()
SERVICE_CONTEXTS = []
if shutil.which('geckodriver'):
SERVICE_CONTEXTS.append(ServiceContext(
driver=Geckodriver(log_file=sys.stdout),
async def get_example_h1_functional(service, engine):
driver = await service.start(engine)
try:
session = await driver.new_session(Firefox())
try:
await session.get('http://example.com/')
element = await session.get_element('h1')
print(await element.get_text())
finally:
await session.close()
finally:
await driver.close()
async def get_example_h1_context_manager(service, engine):
async with service.run(engine) as driver:
async with driver.session(Firefox()) as session:
await session.get('http://example.com/')
element = await session.get_element('h1')
print(await element.get_text())
async def get_example_h1_functional(service, engine):
driver = await service.start(engine)
try:
session = await driver.new_session(Firefox())
try:
await session.get('http://example.com/')
element = await session.get_element('h1')
print(await element.get_text())
finally:
await session.close()
finally:
await driver.close()
async def get_example_h1_context_manager(service, engine):
async with service.run(engine) as driver:
async with driver.session(Firefox()) as session:
await session.get('http://example.com/')
element = await session.get_element('h1')
print(await element.get_text())