简体   繁体   English

用Selenium Ruby脚本绕过“阻止不安全的内容”

[英]Bypassing “Insecure Content Blocked” with Selenium Ruby script

I am fairly new with using Selenium in my Ruby script. 我在Ruby脚本中使用Selenium还是一个新手。 Basically my script will make a get request to some url and log in. However my script is failing to send the email and log in automatically due to the Google Chrome pop up about insecure content blocked since one of the images on the page is using http and not https. 基本上,我的脚本会向某些网址发出获取请求并登录。但是,由于页面上的其中一个图像使用http,因此Google Chrome浏览器弹出了有关不安全内容的阻止信息,因此我的脚本无法发送电子邮件并自动登录而不是https。

I was able to run the script successfully months ago however just recently when trying again, it is unable to proceed with logging in so I dont know why it stopped working all of a sudden. 我能够在几个月前成功运行该脚本,但是就在最近再次尝试时,它无法继续登录,因此我不知道为什么突然停止工作。

The error that I see in terminal is this. 我在终端中看到的错误是这样的。 In irb, I can go through each line of code successfully including using Selenium's "send_keys" and "click" to automatically sign in. 在irb中,我可以成功完成每一行代码,包括使用Selenium的“ send_keys”和“ click”来自动登录。

[2018-09-26T13:02:55.002527 #14131] INFO -- : [#http://company.com/favicon.ico'. [2018-09-26T13:02:55.002527#14131]信息-:[#http://company.com/favicon.ico'。 This request has been blocked; 该请求已被阻止; the content must be served over HTTPS.">] web_app.rb:54:in `': Console Errors Found! (Exception) 内容必须通过HTTPS提供。“>] web_app.rb:54:in'':发现控制台错误!(异常)

I tried searching for some solution but have been unsuccessful. 我尝试寻找某种解决方案,但未成功。 There has been some variations of responses to similar problem but not too much luck with getting it to work. 对于类似问题的响应有一些变化,但要使其正常工作并不会带来太多运气。

Any feedback on how to fix would be appreciated. 任何有关如何修复的反馈意见将不胜感激。

start Chrome manualy and disable the warning - https://www.thewindowsclub.com/disable-insecure-content-warning-chrome Chrome启动manualy和禁用警告- https://www.thewindowsclub.com/disable-insecure-content-warning-chrome

and use the set browser profile, there is my setup: 并使用设置的浏览器配置文件,这是我的设置:

@BeforeClass
public static void setUpClass() {
    System.setProperty("webdriver.chrome.driver", "C:\\Users\\pburgr\\Desktop\\chromedriver\\chromedriver.exe");
    ChromeOptions options = new ChromeOptions();
    options.addArguments("user-data-dir=C:\\Users\\pburgr\\AppData\\Local\\Google\\Chrome\\User Data");
    driver = new ChromeDriver(options);
    driver.manage().window().maximize();}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM