我一直在用Chromedriver测试Selenium,我注意到有些页面可以检测到你正在使用Selenium,即使根本没有自动化.即使我只是通过Selenium和Xephyr使用chrome手动浏览我经常会得到一个页面,说明检测到可疑活动.我检查了我的用户代理和浏览器指纹,它们与普通的Chrome浏览器完全相同.
当我在普通镀铬中浏览这些网站时,一切正常,但是当我使用Selenium的时候,我已经检测到了.
从理论上讲,chromedriver和chrome应该看起来与任何网络服务器完全相同,但不知怎的,他们可以检测到它.
如果你想要一些测试代码试试这个:
from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=1, size=(1600, 902))
display.start()
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--disable-extensions')
chrome_options.add_argument('--profile-directory=Default')
chrome_options.add_argument("--incognito")
chrome_options.add_argument("--disable-plugins-discovery");
chrome_options.add_argument("--start-maximized")
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.delete_all_cookies()
driver.set_window_size(800,800)
driver.set_window_position(0,0)
print 'arguments done'
driver.get('http://stubhub.com')
Run Code Online (Sandbox Code Playgroud)
如果您浏览stubhub,您将在一两个请求中被重定向和"阻止".我一直在研究这个,我无法弄清楚他们如何判断用户是否正在使用Selenium.
他们是如何做到的呢?
编辑更新:
我在Firefox中安装了Selenium IDE插件,当我在普通的firefox浏览器中使用附加插件访问stubhub.com时,我被禁止了.
编辑:
当我使用Fiddler来查看来回发送的HTTP请求时,我注意到"假浏览器"的请求通常在响应头中有"无缓存".
编辑:
这样的结果是否有办法检测到我在Javascript的Selenium Webdriver页面中建议无法检测何时使用webdriver.但是这个证据表明不然.
编辑:
该网站将指纹上传到他们的服务器,但我检查了使用chrome时硒的指纹与指纹相同.
编辑:
这是他们发送到服务器的指纹有效负载之一
{"appName":"Netscape","platform":"Linuxx86_64","cookies":1,"syslang":"en-US","userlang":"en-US","cpu":"","productSub":"20030107","setTimeout":1,"setInterval":1,"plugins":{"0":"ChromePDFViewer","1":"ShockwaveFlash","2":"WidevineContentDecryptionModule","3":"NativeClient","4":"ChromePDFViewer"},"mimeTypes":{"0":"application/pdf","1":"ShockwaveFlashapplication/x-shockwave-flash","2":"FutureSplashPlayerapplication/futuresplash","3":"WidevineContentDecryptionModuleapplication/x-ppapi-widevine-cdm","4":"NativeClientExecutableapplication/x-nacl","5":"PortableNativeClientExecutableapplication/x-pnacl","6":"PortableDocumentFormatapplication/x-google-chrome-pdf"},"screen":{"width":1600,"height":900,"colorDepth":24},"fonts":{"0":"monospace","1":"DejaVuSerif","2":"Georgia","3":"DejaVuSans","4":"TrebuchetMS","5":"Verdana","6":"AndaleMono","7":"DejaVuSansMono","8":"LiberationMono","9":"NimbusMonoL","10":"CourierNew","11":"Courier"}}
Run Code Online (Sandbox Code Playgroud)
它的硒和铬相同
编辑:
VPN仅供一次使用,但在加载第一页后会被检测到.很明显,正在运行一些javascript来检测Selenium.
javascript python selenium google-chrome selenium-chromedriver
当我尝试使用Selenium(Python)登录Chase网站时,我遇到以下错误消息:
但是,使用"人"登录工作正常.似乎当Selenium找到一个元素时会引发问题.
我错过了什么吗?我试图在stackoverflow上找到答案,但无济于事.
预期的结果是脚本将成功允许我以编程方式登录.
这是下面的代码示例:
import time
import os
from selenium import webdriver
CHASE_USER_ID = os.getenv('CHASE_USER_ID', None)
CHASE_PASSWORD = os.getenv('CHASE_PASSWORD', None)
assert CHASE_USER_ID is not None, 'Chase user id not set'
assert CHASE_PASSWORD is not None, ' Chase password not set'
def main():
chrome_options = webdriver.ChromeOptions()
driver = webdriver.Chrome(r'./chromedriver', chrome_options=chrome_options)
try:
driver.get('https://secure07c.chase.com/web/auth/#/logon/logon/chaseOnline?')
time.sleep(2)
user_element = driver.find_element_by_id('userId-input-field') # Finding an element here seems to make the login process fail
user_element.send_keys(CHASE_USER_ID)
password_element = driver.find_element_by_id('password-input-field')
password_element.send_keys(CHASE_PASSWORD)
time.sleep(2)
password_element.submit()
time.sleep(10)
finally:
driver.quit()
if …
Run Code Online (Sandbox Code Playgroud) python selenium google-chrome webdriver selenium-chromedriver
我正在尝试使用selenium和chrome在网站中自动执行一项非常基本的任务,但不知何故,网站检测到chrome由硒驱动并阻止每个请求.我怀疑该网站依赖于一个暴露的DOM变量,如/sf/answers/2933311741/来检测selenium驱动的浏览器.
我的问题是,有没有办法让navigator.webdriver标志为假?我愿意在修改之后尝试重新编译硒源,但我似乎无法在存储库中的任何地方找到NavigatorAutomationInformation源https://github.com/SeleniumHQ/selenium
任何帮助深表感谢
PS:我还从https://w3c.github.io/webdriver/#interface尝试了以下内容
Object.defineProperty(navigator, 'webdriver', {
get: () => false,
});
Run Code Online (Sandbox Code Playgroud)
但它只在初始页面加载后更新属性.我认为该网站在我的脚本执行之前检测到该变量.
java selenium webdriver selenium-webdriver webdriver-w3c-spec
我正在尝试使用 Selenium 从 LV 网站上抓取一些数据,并在单击“登录”按钮后不断收到“访问被拒绝”屏幕。我觉得有一种保护措施可以防止这种情况,因为当我手动执行相同操作时,一切似乎都工作正常。奇怪的是,我需要单击“登录”按钮两次才能手动登录。
我的代码:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options, executable_path=r'chromedriver.exe')
driver.get('https://secure.louisvuitton.com/eng-gb/mylv')
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, "//span[@class='ucm-wrapper']")))
driver.find_element_by_xpath("//button[@class='ucm-button ucm-button--default ucm-choice__yes']").click()
driver.find_element_by_id('loginloginForm').send_keys('xxx@xxx.com')
driver.find_element_by_id ('passwordloginForm').send_keys('xxxxxx')
driver.find_element_by_id('loginSubmit_').click()
Run Code Online (Sandbox Code Playgroud)
错误:
You don't have permission to access "http://secure.louisvuitton.com/eng-gb/mylv;jsessionid=xxxxxxx.front61-prd?" on this server.
Run Code Online (Sandbox Code Playgroud)
有没有办法用 Selenium 登录并绕过这个?
python selenium google-chrome selenium-chromedriver selenium-webdriver
什么是硒?
当您打开Selenium的官方页面时,您首先读到的是“什么是Selenium?”中的“ Selenium automates browser”。部分。“硒的哪个部分适合我?”部分 下面提供了Selenium WebDriver和Selenium IDE之间的选择。据此,我推断出Selenium是工具的集合,该集合包括IDE,WebDriver API(语言绑定),Grid,Selenium Standalone Server,浏览器驱动程序。必须下载适当的文件才能构建项目。
什么是WebDriver?
WebDriver是一个API。它用多种语言编写,这些语言称为语言绑定。API具有控制浏览器的功能。您可以使用这些功能编写脚本来以所需的方式(测试用例)控制浏览器。
这就是我所知道的。如果我错了,请纠正我。我想从面试的角度知道这两个问题的答案。
如果我们创建:
ChromeDriver driver=new ChromeDriver();
Run Code Online (Sandbox Code Playgroud)
chrome 驱动程序方法将被执行。
如果我们创建:
WebDriver driver=new ChromeDriver();
Run Code Online (Sandbox Code Playgroud)
再次ChromeDriver
执行方法[根据方法覆盖]。
那为什么我们只在执行时写后一个呢?
java selenium webdriver selenium-webdriver webdriver-w3c-spec