Does websocket not work with IWebBrowser2::Navigate? - websocket

I am writing small html websocket application. This html page works fine at IE window but if same page is tried to open using IWebBrowser2::Navigate then it throws an error "WebSocket is undefined" in standard java script error message box.
Following is sample javascript code:
function myFunction()
{
ws = new WebSocket("ws://" + "127.0.0.1"+ "8070" +"/" + "NSCOMString");
}
Could you please let me whether websocket is implemented inside the navigate method?
Regards,
Anand Choubey

The IWebBrowser2 control by default runs in compatibility mode, see this article on the IEBlog for details on how to circumvent this behavior.

Related

Selenium get http request ajax url after button click

I need to get the http request URL when a button is clicked in a webpage programatically.
I am using selenium to trace the button and I am performing click on the button. on click of the button it makes a http request and the same can be traced in the network tab of the browser.
How can i get the request URL programatically once I trigger the button click using selenium.
Any other tools or libraries that I can use to achieve the same functions is also ok for me. I just need to be able to get the URL after button click programatically. This is a dynamic URL which changes periodically and the objective is to automate the download process through code.
Thanks in advance for any help!
You can use JavaScript executor to get network data. Please refer https://stackoverflow.com/a/45859018/5966329
get request/response data from there.
DesiredCapabilities d = DesiredCapabilities.chrome();
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.PERFORMANCE, Level.ALL);
d.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
WebDriver driver = new ChromeDriver(d);
driver.get("https://www.google.co.in/");
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
LogEntries les = driver.manage().logs().get(LogType.PERFORMANCE);
for (LogEntry le : les) {
System.out.println(le.getMessage());
}
Python Equivalent:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import
DesiredCapabilities
caps = DesiredCapabilities.CHROME
caps['goog:loggingPrefs'] = {'performance': 'ALL'}
driver = webdriver.Chrome(desired_capabilities=caps)
driver.get('https://stackoverflow.com')
for entry in driver.get_log('performance'):
print(entry)
Please refer thread for more info python

Bypassing "Insecure Content Blocked" with Selenium Ruby script

I am fairly new with using Selenium in my Ruby script. 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.
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.
[2018-09-26T13:02:55.002527 #14131] INFO -- : [#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)
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
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();}

Socket.io not calling connect event in IE8

I have an application which uses socket.io to communicate with the server. In all browsers (i.e. Google Chrome, Firefox, etc.) except IE, the connect event is triggered. See definition below.
var socket = io.connect('xxx.xxx.xxx.xxx:1337');
socket.on('connect', function () {
//code here
});
For some reason, in IE8 this event doesn't get fired. Is there something different I need to do to make that happen?
Check if your JS console shows an "Access is Denied" exception. If so, have a look at:
NodeJS-socket.io getting "Access is Denied" Exception

Watin accessing localhost

When executing the c# code in MSTest involving WatiN
var browser = new IE("http://localhost:56034/");
The web page is displayed in IE but after about a minute, I receive the error
Timeout while waiting for main document becoming available with the error message
Timeout while waiting for main document becoming available
The code
var browser = new IE("http://www.bing.com/");
works fine.
I am running IIS Express 7.5. Since I am new to the WatiN I am hoping that I am missing something simple.
Following the advice in http://spin.atomicobject.com/2010/12/15/watin-and-com-errors-enable-ie-protected-mode-for-local-intranet-zone, turning ON protected mode for the intranet zone in IE 8 solved the problem.

Debugging: IE6 + SSL + AJAX + post form = 404 error

The Setting:
The program in question tries to post form data via an AJAX call to a target procedure contained in the same package as the caller. This is done for a site that uses a secure connection (HTTPS). The technology used here is PLSQL and the DOJO JavaScript library. The development tool is basically a text editor.
Code Snippet:
> function testPost() {
>> dojo.xhrPost( {
url: ''dr_tm_w_0120.test_post'',
form: ''orgForm'',
load: testPostXHRCallback,
error: testPostXHRError
});
}
> function testPostXHRCallback(data,ioArgs) {
>> alert(''post callback'');
try{
dojo.byId("messageDiv").innerHTML = data;
}
catch(ex){
if(ex.name == "TypeError")
{
alert("A type error occurred.");
}
}
return data;
}
>
function testPostXHRError(data, ioArgs) {
>> alert(data);
alert(''Error when retrieving data from the server!'');
return data;
}
The Problem:
When using IE6 (which the entire user-base uses), the response sent back from the server is a 404 error.
Observations:
The program works fine in Firefox.
The calling procedure cannot target any procedures within the same package.
The calling procedure can target outside sites (both http, https).
The other AJAX calls in the package that are not posts of form data work fine.
I've searched the internets and consulted with senior-skilled team members and haven't discovered anything that satisfactorily addresses the issue.
*Tried Q&A over at Dojo support forums.
The Questions:
What troubleshooting techniques do you recommend?
What troubleshooting tools do you recommend for HTTPS analyzing?
Any hypotheses on what the issue might be?
Any ideas for workarounds that aren't total (bad) hacks?
Ed. The Solution
lomaxx, thx for the fiddler tip. you have no idea how awesome it was to get that and use it as a debugging tool. after starting it up this is what i found and how i fixed it (at least in the short term):
> ef Fri, 8 Aug 2008 14:01:26 GMT dr_tm_w_0120.test_post: SIGNATURE (parameter names) MISMATCH VARIABLES IN FORM NOT IN PROCEDURE: SO1_DISPLAYED_,PO1_DISPLAYED_,RWA2_DISPLAYED_,DD1_DISPLAYED_ NON-DEFAULT VARIABLES IN PROCEDURE NOT IN FORM: 0
After seeing that message from the server, I kicked around Fiddler a bit more to see what else I could learn from it. Found that there's a WebForms tab that shows the values in the web form. Wouldn't you know it, the "xxx_DISPLAYED_" fields above were in it.
I don't really understand yet why these fields exist, because I didn't create them explicitly in the web PLSQL code. But I do understand now that the target procedure has to include them as parameters to work correctly. Again, this is only in the case of IE6 for me, as Firefox worked fine.
Well, that the short term answer and hack to fix it. Hopefully, a little more work in this area will lead to a better understanding of the fundamentals going on here.
First port of call would be to fire up Fiddler and analyze the data going to and from the browser.
Take a look at the headers, the url actually being called and the params (if any) being passed to the AJAX method and see if it all looks good before getting to the server.
If that all looks ok, is there any way you can verify it's actually hitting the server via logging, or tracing in the AJAX method?
ed: another thing I would try is rig up a test page to call the AJAX method on the server using a non-ajax based call and analyze the traffic in fiddler and compare the two.

Resources