Set log level for chrome logs in ruby - ruby

I'm trying to assert that there is no mixed content in a website. I have set the log level equal to 1 in the chrome switches , but i m still unable to retrieve warning messages from the browser, here is the code im using.
browser = Watir::Browser.new :chrome,
switches: %w[--disable-gpu --no-sandbox
--disable-prompt-on-repost
--windows-size=3200x1800
--log-level=1]
console_log = browser.driver.manage.logs.get (:browser)
What am i doing wrong? or there is other way to set this log level to capture errors and warnings?

Work done ,, just changing the way i was passing the settings to the browsr is working
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--disable-infobars')
options.add_argument('--disable-gpu')
options.add_argument('--no-sandbox')
options.add_argument('--disable-prompt-on-repost')
options.add_argument('--user-agent="Mozilla/5.0 (Linux; Android 6.0.1; SAMSUNG SM-G925F Build/MMB29K) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/4.0 Chrome/44.0.2403.133 Mobile Safari/537.36"')

Related

Accessing web-cam using Cypress

I am trying to automate a web-app (company specific) using Cypress which contains a page to take a picture using a web-cam. On clicking the 'Take a Photo' button, it shows an error message asking to provide access to the camera.
But, a browser pop-up is not displayed asking for permissions unlike the open-source website - https://webcamtests.com/
On looking at Cypress documentation, a default set of Chrome switches are being added to the browser before the launch which also includes
'--use-fake-device-for-media-stream'
'--use-fake-ui-for-media-stream'
I've removed them using the below code that is placed in the config file .
launchOptions.args = launchOptions.args.filter((arg) => {
return arg !== '--use-fake-device-for-media-stream' && arg !== '--use-fake-ui-for-media-stream'
})
Also, in the documentation it specifically says this reg the default switches- https://docs.cypress.io/guides/guides/launching-browsers#Launching-Browsers
"Disables prompts requesting permission to use devices like cameras or mics"
Am looking to see what is the corresponding switch for this and is there a way to enable the prompt to provide access?
Any help/suggestion is appreciated.
Cypress Version: 12.5.1
Chrome Version: 109
Platform - Mac
Note:
I've also tried using an open source library for enabling the camera permissions but it did not work.
https://github.com/kamranayub/cypress-browser-permissions
The prompt is displayed when automated using Web-Driver.
Please try this:
cy.request({
method: 'GET',
url: 'https://webcamtests.com/',
headers: {
'Content-Type': 'text/html',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36'
},
followRedirect: false,
body: {}
});
Above test simulate a real user request to the target website and trigger camera permissions pop-up.
Please keep in mind, it might not work for all websites as the pop-up is controlled by the website and user's browser.

Regarding issue 500 service unavailability in drupal 7

Hope you Guys are doing good. I have 1 issue with my project functionality. I have 1 form in that form we have few fields and in last we have submit and download button. when we will click on submit and download button that time we will this error.
POST https://admin.default.com/manage_doc_download_popup/ajax/2091/674?token=... 500 (Service unavailable (with message)) Response Text: [{"command":"settings","settings":{"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"capstore","theme_token":"gcu_X3w1KcbG7Lq6TmlXVMOupzbkdowwVgbpz_a-Xlo","js":{"sites\/all\/modules\/contrib\/ctools\/js\/ajax-responder.js":1}},"lightbox2":{"rtl":0,"file_path":"\/(\\w\\w\/)public:\/","default_image":"\/sites\/all\/modules\/contrib\/lightbox2\/images\/brokenimage.jpg","border_size":10,"font_color":"000","box_color":"fff","top_position":"","overlay_opacity":"0.8","overlay_color":"000","disable_close_click":1,"resize_sequence":0,"resize_speed":400,"fade_in_speed":400,"slide_down_speed":600,"use_alt_layout":1,"disable_resize":0,"disable_zoom":0,"force_show_nav":1,"show_caption":0,"loop_items":0,"node_link_text":"View Image Details","node_link_target":0,"image_count":"Image !current of !total","video_count":"Video !current of !total","page_count":"Page !current of !total","lite_press_x_close":"press \u003Ca href=\u0022#\u0022 onclick=\u0022hideLightbox(); return FALSE;\u0022\u003E\u003Ckbd\u003Ex\u003C\/kbd\u003E\u003C\/a\u003E to close","download_link_text":"Download Original","enable_login":false,"enable_contact":false,"keys_close":"c x 27","keys_previous":"p 37","keys_next":"n 39","keys_zoom":"z","keys_play_pause":"32","display_image_size":"","image_node_sizes":"()","trigger_lightbox_classes":"","trigger_lightbox_group_classes":"","trigger_slideshow_classes":"","trigger_lightframe_classes":"","trigger_lightframe_group_classes":"","custom_class_handler":0,"custom_trigger_classes":"","disable_for_gallery_lists":true,"disable_for_acidfree_gallery_lists":true,"enable_acidfree_videos":true,"slideshow_interval":5000,"slideshow_automatic_start":true,"slideshow_automatic_exit":true,"show_play_pause":true,"pause_on_next_click":false,"pause_on_previous_click":true,"loop_slides":false,"iframe_width":900,"iframe_height":520,"iframe_border":0,"enable_video":1,"useragent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/86.0.4240.193 Safari\/537.36","flvPlayer":"\/sites\/default\/files\/DCXCOE_DX_sv.mp4","flvFlashvars":""},"overlay":{"paths":{"admin":"file\/*\/downloads\nfile\/add\nfile\/add\/*\nfile\/*\/edit\nfile\/*\/usage\nfile\/*\/delete\nnode\/*\/edit\nnode\/*\/delete\nnode\/*\/revisions\nnode\/*\/revisions\/*\/revert\nnode\/*\/revisions\/*\/delete\nnode\/add\nnode\/add\/*\noverlay\/dismiss-message\nuser\/*\/shortcuts\nadmin\nadmin\/*\nbatch\ntaxonomy\/term\/*\/edit\nuser\/*\/cancel\nuser\/*\/edit\nuser\/*\/edit\/*\nnode\/*\/moderation\nnode\/*\/moderation\/*\/unpublish\nnode\/*\/moderation\/*\/change-state\/*\nnode\/*\/moderation\/view\nnode\/*\/moderation\/diff\nnode\/*\/moderation\/diff\/list\nnode\/*\/moderation\/diff\/view\nnode\/*\/moderation\/diff\/view\/*\/*","non_admin":"admin\/structure\/block\/demo\/*\nadmin\/reports\/status\/php"},"pathPrefixes":[],"ajaxCallback":"overlay-ajax"},"bootstrap":{"anchorsFix":"0","anchorsSmoothScrolling":"0","formHasError":1,"popoverEnabled":1,"popoverOptions":{"animation":1,"html":0,"placement":"right","selector":"","trigger":"click","triggerAutoclose":1,"title":"","content":"","delay":0,"container":"body"},"tooltipEnabled":1,"tooltipOptions":{"animation":1,"html":0,"placement":"auto left","selector":"","trigger":"hover focus","delay":0,"container":"body"}}},"merge":true},{"command":"insert","method":"prepend","selector":"head","data":"\u003Cscript src=\u0022https:\/\/admin.default.com\/sites\/all\/modules\/contrib\/ctools\/js\/ajax-responder.js?qjdm9a\u0022\u003E\u003C\/script\u003E\n","settings":null},{"command":"invoke","selector":".comment-form","method":"show","arguments":[]},{"command":"invoke","selector":".comment-section .fivestar-widget","method":"removeClass","arguments":["pointer"]},{"command":"css","selector":".comment-section .fivestar-widget div.on:last a","argument":{"width":"100%"}},{"command":"redirect","url":"https:\/\/admin.default.com\/file\/2091\/download?token=OEJk7avE","delay":0,"new_window":false},{"command":"modal_dismiss"}]
and will get error in this line in JS file
xhr.send( ( s.hasContent && s.data ) || null );
So guys if you have any idea about this please help me.And I'm new in this project so I don't know, how to start.. Please help guys. I have attached few images related to issue that will help to understand what the issue is.[Error 1] [Error 2]
Please help guys..!!!

setUserAgent no longer avialble in HtmlUnit 2.28?

The code below works fine in HtmlUnit 2.27, but the setUserAgent method is not available in 2.28 what is the correct way of setting the useragent now?
BrowserVersion bv = BrowserVersion.CHROME;
bv.setUserAgent(
"Mozilla/5.0 (Linux; Android 6.0; XT1063 Build/MPBS24.65-34-4; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/59.0.3071.125 Mobile Safari/537.36");
Starting with 2.28 it is no longer possible to modify the build in browser versions. There are various reasons for this and we had some discussions about possible fixes on our mailing lists.
In the end we are using a factory pattern to setup new browser configurations and make them unchangeable afterwards.
final BrowserVersionBuilder myChromeBuilder = new BrowserVersion.BrowserVersionBuilder(BrowserVersion.CHROME);
// do your setup here
myChromeBuilder.setXXX(..);
final BrowserVersion myChrome = myChromeBuilder.build();
If you like you can also use a more fluent style for the code
final BrowserVersion myChrome = new BrowserVersion.BrowserVersionBuilder(BrowserVersion.CHROME)
// do your setup here
.setXXX(..)
.build();

Selenium driver for remote browser

I am using selenium-webdriver and running this test on a remote machine.
I want to redirect the user to the mobile website by changing the user agent.
I tried with the following, but it doesn't work.
require 'selenium-webdriver'
capabilities = Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => 'Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10')
browser = Selenium::WebDriver.for :remote, :desired_capabilities => capabilities
browser.get "http://mobile.website.com/"
I am getting this error on my browser
Selenium::WebDriver::Error::WebDriverError (Could not find Firefox binary (os=linux). Make sure Firefox is installed or set the path manually with Selenium::WebDriver::Firefox::Binary.path=):
a. Is there any way to achieve this without using selenium?
b. Is there any way to detect the user's browser and redirect the user to URL with the mobile user agent string(iphone,android)?
Why not test your website in a real mobile device, e.g. using Appium.
You can use Appium to drive the browser in your mobile.

What does the UserAgent "LSIE" stand for?

Recently, there are some visits to my site with UserAgent "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; LSIE 1.1.8.4)". What does the "LSIE" stand for?
LSIE is an additional information added to the UserAgent string
Usually a part of the UserAgent is used to add additional info about the used browser/machine/factory; LSIE seems to be an additional info added from BenQ-Siemens systems.
LSIE stands for "large scale internet extraction," which was program by the government to scrape the internet.
After Snowden's revelations the project's name was changed. I think the new name was "Everest."

Resources