Closed User-Clb closed 7 months ago
Following works just fine:
from selenium_driverless.sync import webdriver
from selenium_driverless.types.by import By
from selenium_driverless import webdriver
import asyncio
import re
async def target_1_handler(target):
await target.get('https://abrahamjuliot.github.io/creepjs/')
print(await target.title)
elem = await target.find_element(By.XPATH, '//*[@id="fingerprint-data"]/div[2]/div/div[1]/div[1]/span', timeout=20)
await asyncio.sleep(1)
elem = await target.find_element(By.XPATH, '//*[@id="fingerprint-data"]/div[2]/div/div[1]/div[1]/span', timeout=20)
text = await elem.text
[(percent, letter)] = re.findall(r"(\d{1,3}\.?\d?)% ([A-Z])", text)
percent = float(percent)
print(f"got {percent}% ({letter})")
async def target_2_handler(target):
await target.get("https://pypi.org/project/selenium-driverless/#description")
print(await target.title)
print(await target.find_element(By.XPATH,'//*[@id="description"]/div/h1'))
async def main():
options = webdriver.ChromeOptions()
async with webdriver.Chrome(options=options) as driver:
target_1 = await driver.current_target
target_2 = await driver.new_window("tab", activate=False)
await asyncio.gather(
target_1_handler(target_1),
target_2_handler(target_2)
)
await target_1.focus()
input("press ENTER to exit")
asyncio.run(main())
@User-Clb This is a warning! Please don't open any issues unless there's a bug. I don't have the resources to fix user-side issues.