admin管理员组

文章数量:1310461

The below example:

from seleniumbase import SB
    
with SB(uc=True, locale_code="en", headless=True) as sb:

link = "/"

print(f"\nOpening {link}")

sb.wait_for_ready_state_complete(timeout=120)

sb.activate_cdp_mode(link)

print(f"Sleeping for some time...")
sb.sleep(5)

[screenwidth,screenheight,innerwidth,innerheight,scrollwidth,scrollheight] = sb.cdp.evaluate("return [window.screen.width, window.screen.height, window.innerWidth, window.innerHeight, document.documentElement.scrollWidth, document.documentElement.scrollHeight];")

print(f"Size: {screenwidth}, {screenheight}, {innerwidth}, {innerheight}, {scrollwidth}, {scrollheight}")

sb.cdp.set_window_rect(0,0,scrollwidth + screenwidth - innerwidth, scrollheight + screenheight - innerheight + 100)

print(f"Sleeping for some time...")
sb.sleep(5)

sb.cdp.save_screenshot(f"screenshot.png")

print(f"Finished!")

Fails the WEBDRIVER test as it's shown in red color below:

How can I prevent this?

EDIT:

I think I found this issue here

where the author says that he gets the same result as when using a regular Chrome browser, so the Inconsistent value for Webdriver there isn't accurate.

The below example:

from seleniumbase import SB
    
with SB(uc=True, locale_code="en", headless=True) as sb:

link = "https://antoinevastel/bots/"

print(f"\nOpening {link}")

sb.wait_for_ready_state_complete(timeout=120)

sb.activate_cdp_mode(link)

print(f"Sleeping for some time...")
sb.sleep(5)

[screenwidth,screenheight,innerwidth,innerheight,scrollwidth,scrollheight] = sb.cdp.evaluate("return [window.screen.width, window.screen.height, window.innerWidth, window.innerHeight, document.documentElement.scrollWidth, document.documentElement.scrollHeight];")

print(f"Size: {screenwidth}, {screenheight}, {innerwidth}, {innerheight}, {scrollwidth}, {scrollheight}")

sb.cdp.set_window_rect(0,0,scrollwidth + screenwidth - innerwidth, scrollheight + screenheight - innerheight + 100)

print(f"Sleeping for some time...")
sb.sleep(5)

sb.cdp.save_screenshot(f"screenshot.png")

print(f"Finished!")

Fails the WEBDRIVER test as it's shown in red color below:

How can I prevent this?

EDIT:

I think I found this issue here

https://github/seleniumbase/SeleniumBase/issues/3059

where the author says that he gets the same result as when using a regular Chrome browser, so the Inconsistent value for Webdriver there isn't accurate.

Share Improve this question edited Feb 4 at 0:37 Ajeet Verma 3,0813 gold badges17 silver badges28 bronze badges asked Feb 3 at 23:06 sudoExclamationExclamationsudoExclamationExclamation 8,80210 gold badges51 silver badges119 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I found a similar issue here

https://github/seleniumbase/SeleniumBase/issues/3059

where the author says that he gets the same result as when using a regular Chrome browser, so the Inconsistent value for Webdriver there isn't accurate.

I tested it on a regular Chrome browser and I also got the same Inconsistent value. So author is correct.

SeleniumBase with CDP passes the other sites below:

https://deviceandbrowserinfo/info_device

https://bot.sannysoft

https://demo.fingerprint/playground

https://bot-detector.rebrowser

https://pixelscan

本文标签: selenium webdriverSeleniumBased in CDP Mode fails web driver fingerprintStack Overflow