Watir, Automation on Windows 7 with IE8 - windows

I am trying to run watir scripts on Wndows 7 on IE8 as administrator.
Here is problem description:
Problem was with below statement(popup windows)
popup = Watir::IE.attach(:url, /ContactDetails/)
and Error message was Unable to locate the url(ContactDetails)
The issue seems to be that when there already exists an instance of IE8 that was opened with administrative privs, Watir won't see any other IE8 windows that are being run as admin, including ones it opens itself.
Fix that i have been doing:
Turn off User Account Control (set to the lowest setting). Go to Control Panel->System and Security->Action Center->Change User Account Control settings, and drop the slider to the lowest setting.
But this is not a permanent fix, i have to change the windows 7 settings every day to run my automation script.
Can anyone help me finding out the permanent solution ?

As far as I know, watir-webdriver does not have IE class and attach method.

Have you tried to attach via the title of the page? for example:
browser2 = Watir::IE.attach(:title, "Google")
if the browser you wanted to attach to was Googles home page.
Look at the source code and
put whatevers inbetween the title tags on your page.
Google

Related

Selectors only work when webpage is opened in Internet Explorer

I created a login sequence and my selectors for the input email, password, click login and element exists are valid. But only when I have the Internet Explorer page open on the website I'm working with.
I did that sequence again, and I ran it, initially it worked but when I ran the hole project it broke again, I tried "repair" and "indicate", I tried to eliminate the title but nothing is working.
As far as I can see, you are using selector attribute:
"title=ACME System 1 - Dashboard"
Try using a wildcard: title='ACME System 1*', so it can work when you leave the dashboard.
This worked for me when I took those UiPath Academy courses.
In order to automate tasks within a browser with UiPath, the browser must be open. There is an activity called Open Browser that's included in the default activities for every project. You need to add this activity to the beginning of your sequence and pass in the appropriate parameters, (ie. URL, browser type) you can then pass the outputted browser variable to an attach browser sequence and execute your browser automation acivities within that.
Browser activity sceenshot
In addition, the selector that you have shared does not look like a stable selector. There may be other 'H1' elements on the screen that will cause your automation to fail. I would use the UI explorer to help you build a better, more stable selector.
Did you initially use IE to indicate screen elements and then changed the BrowserType property to use a different browser? Please share the sequence to suggest you a fix for your issue.
I would also suggest you to modify the selector to 'title='ACME System *'.
In order for selector to work the application needs to be open and the desired element needs to be available. So when you close the browser the selector disappears.
You may consider swithching to 'Modern Design Experience' and use 'Use Application/Browser' scope to make this more intuitive, and it will also automatically open the browser for you if it is closed.

WatiN downloading files

I am trying to use WatiN to do some screen scraping type of work. It runs on our site on a scheduler. I have no need to see the UI, I just need it to do the work. I can navigate the sites with no issue , but when trying to downlaod the files I have 2 problems.
Using IE 11 when it comes time to download , I get stuck on the open/save dialog that pops up. I have tried and tried and tried everything to have IE 11 auto download files, but to no avail. I edited the registry, and tried every option in the security tab, but no luck. I tried using SendKey.Sendwait("{TAB}"), to mimic what would need to be pressed , but I get "access denied" I think the "ui" is locked.
so I tried Firefox, firefox is easy to configure "automatic downlaods" .... but
FireFox wont even connect, I get: No connection could be made because the target machine actively refused it 127.0.0.1:9997 I installed the appropriate jjsh addon and install it globally for all users from the command line, but still no luck.
Any suggestions on how to disable that yellow bar that IE 11 puts at the bottom of the screen to annoy you , or what I might try with firefox? I believe configuring IE 8 to disable the yellow dialog bar is possible, but I am on a windows 8 machine , so I'm stuck with IE 11, or possibly 10.
You can keep trying to find a solution but that solution will probably break in a next release of IE (based on previous experience) to be able to finally solve and be future proof (if there's such a thing in development....) I would suggest to navigate to the page that has the link and get the HREF portion of it and once you have that link just do the download using other ways, like the following:
(this is just pure C#, not watin)
string downloadURL = "http://example.com/retrievePDF.jsp?id=XXXXX";
client.DownloadFile(downloadURL, #"C:\temp\" + fName + ".pdf");
you should replace the downloadURL with the value on the HREF of your download link and you will be able to find the file where you specify it.

VS Express 2013 for Web - Browser is security restricted or JavaScript is disabled

I initially installed the Microsoft Visual Studio Express 2013 for Web on my desktop. My desktop runs Windows 8.1 with internet explorer 11. It ran fine until the license expired after the first 30 days. I tried to sign in to renew the license, however after clicking the 'sign in' button I get an error dialog. The dialog states 'Browser is security restricted or javaScript is disabled. I have no other option but to close and exit Visual Studio.
I went to the online forums for Microsoft. There were discussions and suggestions on how to fix the error. I tried lowering the settings for the security tab in internet explorer. I have validated the option for scripting is enabled. I have also added https://*.visualstudio.com to the trusted sites tab. Other users on the forum have tried the same suggestions and have not succeeded in signing into the visual studio application.
I had exactly the same problem, here is what I did:
a) Go in IE, click on settings wheel then Internet Options and Security tab.
b) Click on Custom level button (make sure you select Internet zone).
c) In Security Settings window, under Scripting I set Enabled for Active scripting.
After that Sign In should work. Even though Chrome is default browser, it seems that VS uses IE for sign in process.
Hope this helps!
There is another issue people are running into that is a bug with the login dialog. The login dialog is using a Web Browser control to login the user. By default it loads up "about:blank" as the URI. It then proceeds to try to execute some JavaScript (just ";") to verify it has permissions to do so. On some machines this is problematic because "about:blank" has been mapped to zone 0, or the Local Machine zone. When the JavaScript is executed MSHTML will check the zone of the URI and then the policy for executing scripts. By default the Local Machine zone is locked down, and all script executions result in a Query policy. What this means is if you're running in immersion mode (aka in Internet Explorer) you will get a message box asking if you want to execute the script. However, the Web Browser control used by VS 2013's "Sign In" dialog doesn't run MSHTML code in immersion mode, so the Query policy effectively equates to a Disallow policy. The bug here is someone in VS assumed "about:blank" resolves to the Internet zone, and when it resolves to the Local Computer zone you get this behavior.
The workaround is to remove "about:blank" zone mapping. Point regedit to this key:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains]
Remove the "blank" key.
Alternatively you can change the Local Machine Lockdown policy for executing scripts. The reg key for that is:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Lockdown_Zones\0]
Set the "1400" DWORD value to 0.
There are many sites you need to list in your Trusted Sites. Following the trace of what the stupid, stupid login script does:
https://.visualstudio.com
https://app.vssps.visualstudio.com
https://.accesscontrol.windows.net
https://auth.gfx.ms
https://login.live.com
Only then was I able to log on to my FREE software.
Hi this is Albert from Microsoft. Just want to let you all know that this issue has been fixed in the upcoming Update 2 for Visual Studio 2013. Thanks for your patience while we figured this one out :)
Same problem "Browser is security restricted or JavaScript is disabled" here but the solution from #jic didn't work for me..
If you can and it is convenient for you this is a solution which worked for me:
I have created a new user/profile on my PC and for this user it was just working fine.
Before this action I have tried to make an user account which had this problem as:
Power user - didn't work
Administrator - didn't work as well
So the last solution in my case was a brand new user on the PC..
Here's what worked for me.
Open Control Panel, Internet Options.
First, I clicked the Security tab and turned security the security for the Internet zone to its minimum.
Next, click the Privacy tab, then click Advanced. Choose "Accept" for both types of cookies.
Of course you can change these all back after extending your VS trial.
you must change secure settings of iexplore for admin account. If logon by other account, you must start iexplore under admin account or logon under admin account, because you will get license after admin account.
Click on Start --> Run --> type cmd and click on OK.
Command Prompt will be opened. Then enter this command.
ipconfig /flushdns
and press Enter.
Now try to access https://app.vssps.visualstudio.com/Profile/View
It worked for me...
As I can not add a comment yet to the answer of CBGraham, I've to add this note over here:
The solution described from CBGraham worked for me (Thanks Graham). I had to add an additional link:
https://account.live.com
Then I opened the IE and tried to login to a Microsoft site. I left the IE window open and just clicked once again on the VS to login. Then it worked for me. Even with strong restrictions on the IE settings. While I'm surprised why someone should set down his security settings, just to register VS.

HTML parsing error in IE8(KB927917)

Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727)
Timestamp: Wed, 18 Jan 2012 05:02:49 UTC
Message: HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
Line: 0
Char: 0
Code: 0
URI: http://collaborize.collaborizeclassroom.com/portal/portal/collaborize/site/window?actionEvent=homePage&action=2&fpg=1&unId=umb8N95lhIoXOVKzTTrtcPoCrixd4wMdScQv8mEwqFT962zy3VSh4mzQNeugOWVV&ts=1326862916939&publishUrl=class2&siteName=class2&siteId=20941
I get the above problem only when i open and close the browser and log-in for the first time and even though i delete cache,cookies and history and login again i don't get the problem.
is there something else other than the above that gets deleted when we close the browser because the error only comes when i login the first time after i open the browser
Example: call document.body.appendChild when the page has not loaded.
Need to call javascript when the page is loaded, example:
document.body.onload = function()
{
document.body.appendChild(...)
}
Add few characters spaces in-between script tags to fix this.
ie., space inbetween start and close script tags in case you are referring outside library using src attribute
IE takes some time to render elements. In that case, if we are referencing the element in Javascript it will throw this error.
Solution is to check on your Javascript or Jquery codes and use the codes inside the $(document).ready(function() { } function.
It works for me.
This is a bug in IE8.try following the method provided below. After using this my problem is resolved.
Reset your Internet Explorer settings and run it. You can do this by following the steps given below.
If the problem is caused by damaged or incompatible Internet Explorer settings or add-ons, you can usually resolve the problem by resetting Internet Explorer settings.
To use the Reset Internet Explorer Settings feature from Control Panel, follow these steps:
First of all clear your IE history.
Exit all programs, including Internet Explorer (if it is running).
If you use Windows XP, click Start, and then click Run. Type the following command in the Open box, and then press ENTER:
inetcpl.cpl
If you use Windows Vista, click Start Collapse this imageExpand this image . Type the following command in the Start Search box, and then press ENTER:
inetcpl.cpl
The Internet Options dialog box appears.
Click the Advanced tab.
Under Reset Internet Explorer settings, click Reset. Then click Reset again.
When Internet Explorer finishes resetting the settings, click Close in the Reset Internet Explorer Settings dialog box.
After that you have to download the Cumulative Security update for Internet Explorer KB2360131 to resolve this.
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=27630 (Windows XP)
OR
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=27622 (Windows Vista)
-- Start Internet Explorer again.
Not sure if this will be on any help but it might give you an idea of your problem.
I'm still learning js but I got the same problem and only in IE8. I had suspicion that it was the facebook plugin I got from facebook which stated to place the code at the top of page. I removed the code and page loaded without error then added it back and I got the error. I moved the code to the bottom of the page and it worked with no errors. The page even loaded faster.
I added the $(document).ready(...) and still had a problem. After further analysis, I isolated the problem to an em value in a CSS media query (I am using respond.js). I have not investigate the root cause further, but I was able to consistently view the page without errors after switching the media query from ems to pixels.
The problem happens when JS tried to appendChild to a DOM element that has not finished loading. I fixed with
window.onload=function() {
//append code
}
if the issue is still happening within here I would surmise that the ready code is creating new elements and trying to append children to them before they are loaded.
To solve the issue:
Please check your source codes, that all the HTML tags are opened and closed properly.
If all are fine then you will not get this kind of errors in IE.

Internet Explorer 8 64bit and Selenium Not working

I am trying to get selenium tests to run. Yet every time I try to run a tests that should run IE I get a error on line 863 of htmlutils.js It says that I should disable my popup blocker. The thing is I went to IE tools-> turn of popup block.
So it is disabled and I get this error.
Is there something else I need to disable. I actually don't even know what version of Internet explorer it is running since I am using Windows 7 Pro 64bit version. So when I do use IE I use 64bit version but I am under the understanding if the site or something like that does not support 64bit it goes to 32bit.
So not sure what I need to do it to make it work.
This is the lines where it does
function openSeparateApplicationWindow(url, suppressMozillaWarning) {
// resize the Selenium window itself
window.resizeTo(1200, 500);
window.moveTo(window.screenX, 0);
var appWindow = window.open(url + '?start=true', 'selenium_main_app_window');
if (appWindow == null) {
var errorMessage = "Couldn't open app window; is the pop-up blocker enabled?"
LOG.error(errorMessage);
throw new Error("Couldn't open app window; is the pop-up blocker enabled?");
}
Where is this log.error message stored? Maybe I can post that too.
I had a similar problem on Vista and IE8
I would get the same error message
Couldn't open app window; is the pop-up blocker enabled?"
Running my remote control as Admin wasn't an option for me, and also a poor idea from a security perspective.
So in the end I manage to solved this by changeing browser from "*ietha" to "*iexploreproxy"
grid_configuration.yml
hub:
port: 4444
...
- name: "Internet Explorer 8 on Vista"
browser: "*iexploreproxy"
...
Alternatively, you can change browser string from the code:
ISelenium selenium = new DefaultSelenium("localhost", 4444, "*iexploreproxy", "http://www.google.com/");
Works like a charm.
The only question remaing is if this somehow affects the outcome of the test cases. So far no, but I'll update this answer in case that would happen.
I ran into this on Windows 7 64bit.
My solution was:
Disable popup block. - Select "Tools/Popup Blocker/Turn off pop-up blocker"
Disable IE protected mode. - Untick "Tools/Internet Options/Security/Enable protected mode"
It'd be better just to disable protected modes for known trusted hosts/addresses. I'll leave that as an exercise for the reader.
I was experiencing the same problem. I ran the Selenium RC server as an administrator and everything worked fine.
I, too, am experiencing this very problem on a Windows 7 64bit box, trying to run Selenium on it to test and ASP .Net MVC application, written in C#.
I am still trying to work out the answer for myself, but I thought I'd post here to tell you of a little progress I have made in getting something to work, albeit in Firefox instead of IE.
Here's the line I changed:
selenium = new DefaultSelenium("localhost", 4444, "*chrome C:/Program Files (x86)/Mozilla Firefox/firefox.exe", "http://www.bbc.co.uk/");
I would ideally like for this to work in Internet Explorer 8, but if for the moment, I can begin getting tests working and later change over to use IE again, then great.
Hope this helps for your problem with it all.
I had the same problem on Windows 7 64bit IE8. The first step was to disable the IE popup blocker. Then, I got a message in the status bar saying that "Pop-ups were blocked on this page. Press the 'Ctrl' key to allow the pop-ups".
It turns out that the Google Toolbar was providing this feature. Disabling it solved the problem. View > Toolbars > Google to toggle.
John.
If you happen to be doing this from JavaScriptMVC, there is a reference you need to change in \jmvc\plugins\test\drivers\selenium.js:
1) Change iexplore to iexploreproxy and you should get better results:
msie : (/iexploreproxy/i).test(browserStartCommand),
2) At this point, you'll find that you still get the popup error, but a separate instance of IE has started. Leave that IE window open and restart the tests, but not Selenium.
3) Next, the windows should show up in the right place, but IE gives the annoying block active content warning. Allow the content to run and restart the tests, but not Selenium itself.
This is super clunky, but it at least gets you past that part. If I find more methodical ways to do these things I'll update as needed.
I have had the same problem and have found another solution which works for me. Just use the *iexploreproxy setting in the browserString.
I used:
selenium = new DefaultSelenium("localhost", 4444, "*iexploreproxy C:/Program Files/Internet Explorer/iexplorer.exe", "http://www.bbc.co.uk/");
I hope that works for others too :)
You can start the test when you disable the Security mode of Internet. Don´t know the correct name for it, but in dutch it is beveiligde modus.
I tried modifiing the security settings to dublicate this security mode, but couldn´t find the correct setting for it. It must therefor block more then you can set manually.

Resources