WatiN embedded in web browser control not showing dialog window - watin

I have created a .Net C# application in which I have embedded the WatiN inside the webbrowser control.Following is my code
Settings.AutoStartDialogWatcher = false;
IE ie = new IE(WebBrowser1.ActiveXInstance);
This works fine for all controls except for FileDialog. When automating the FileDialog control, the code is as below
ie.FileUpload(Find.ByName("Fileupload_1")).Set("c:\test.pdf");
When this code runs, since the dialogwatcher is not available, it shows an error.
Please help me on this. Thanks in Advance.

I haven't used this approach with file upload, but assuming that this fails because of dialog watcher absence, create your own dialog watcher to handle dialogs of your winform. It is not too hard to rewrite original dialog watcher. Unfortunately, I can't find my code to help you directly.

Related

How to programmatically open a website and click buttons

How to use VBScript to implement the following:
Open web browser
Load a URL in web browser after opening
List item
Click buttons in the loaded browser
Is this possible using VBScript. Any examples of code to help get me started would be beneficial. Also, my web browser is Chrome.
There is a Selenium webdriver created that works with VB.NET, VBA, and VBScript. Download and install the exe.
There are also lots of example scripts that show loading different browser types or in your case Chrome. Once loaded you just need to program what elements to navigate and click after loading your specific URL.
There might be other ways to launch and run commands against the web browser using VBScript. This is just one way.
SeleniumBasic v2.0.9.0 created by Florent Breheret and open source via git hub.
A Selenium based browser automation framework for VB.Net, Visual Basic Applications and VBScript
Script Example:
Set driver = CreateObject("Selenium.ChromeDriver")
driver.Start
WScript.Echo "Click OK to quit"
driver.Quit
Here is the official SELENIUM page: selenium main page
UPDATE:
Here is a second option that is based on the same concept , but implemented a little different. I am not sure it meets your needs , but thought I would include it as another example.
VBS WebDriver
Examples using the VBS WebDriver which is intended to provide a simple binding for Selenium 2. The bindings include the full functionality of Selenium 2 (WebDriver).
If you press F12 in Internet Explorer you can lie about what browser you are using. Use the compatibility tab (a downward direction play icon) and enter your UA string for a browser they support.
See https://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx

Creating options page for BHO

I am creating an IE browser extension using BHO,
I would like to create an option page like the on chrome or firefox.
I want this page to be accessible using manage add-ons page like it works in chrome and firefox. Is it possible? how do I do that?
I am using visual studio ATL and c++
Your Best Best is adding Context Menu or Tools Menu Item.
Basically There is no Standard IE Options Dialog that you can merge your stuff into.
you are gone have to have your own dialog.
as a warning starting with IE10 and IE11. your IE-Addons (BHO,Menu,Toolbar,DeskBank) will not have any access to registry or file system.
if you need to save some stuff. you are gone have to probably create a broker process.
for instance you need to create a windows service that listen on a socket (maybe some random port) and yo you can communicate with it from your options dialog on what to save and what to read.
Inserting context Menus into IE
Inserting Menu Options

How to handle pop up/lookup windows in selenium

I am doing some web automation using Selenium RC. Am new to Selenium RC and am facing problems (may be learning curve) while doing automation. I am using java with Eclipse IDE to code selenium RC.
Scenario: I have a screen with a link. while clicking, it will open a lookup window which contains lot of names (grid). Now I have to select a value from grid by directly clicking any row/record. Or I can use search option and select the record. The problems are
my recorded script is NOT responding to pop-up windows.
Is there any command for "double-click" in selenium.
#rs79 - It didn't work for me. Here is my code:
selenium.click("link=eName"); //click the link to open the lookup window
//lookup window
selenium.focus("Associate"); <br>
selenium.waitForPopUp("Associat", "20000");
selenium.selectWindow("Associat");
selenium.type("id=SearchTextBox", "xyz"); //Enter the text in search field of lookup
selenium.click("id=SearchButton"); // click search button on lookup window <br>
Please correct me if I am wrong. Appreciated if anyone give me more suggestions.
Without access to your DOM, I would recommend recording using the IDE, and adapting the right context from the recorded actions into RC. The IDE does a decent job of capturing the context for popups and modals.
After the capture, here are some gotchas:
For iFrames, change the captured frame id to a more generic (css) locator
Be wary about the difference between selectWindow() and selectFrame()
If its a popup not an popup window then you can try the firebug to locate the element or record you want.
Now copy its xpath and use it in your code.
Same problem I have faced and solved by this method as xpath from fire bug is detailed and locates the proper window.
After coping xpath please verify the path has // at starting.
Thanks
This will help to handle salesforce lookups
Iterator it = windows.iterator();
String parentwindow =(String) it.next();
String childWindow =(String) it.next();
// Switch to parent window
driver.switchTo().window(childWindow);
MiscUtils.pauseForElementToBePresent(3000L);
driver.switchTo().frame("your frame NAME/ID");
MiscUtils.pauseForElementToBePresent(3000L);
// your step to perform on child page.
driver.findElement(By.linkText("123Test")).click();
MiscUtils.pauseForElementToBePresent(3000L);
//if popup is getting close automatically switch to parent window otherwise use "driver.quit();" to close popup
driver.switchTo().window(parentwindow);
driver.switchTo().defaultContent();

How to handle wizard by WATIN in IE8

I am using WATIN Version(1.3.0)
I am in a situation that when i click on a node ,a Wizard appear. That wizard contain several controls(checkboxes,buttons and TextFields) and it has many screens(when next button is pressed , the next screen appear) but i am unable to handle it. I have apply the following techniques but failed
I have used ie.HtmlDialog but exception appear
I have grab the internal iframe (which is the main frame) but its HTMLDocument contains nothing. Where as i contain HTML when i look into it using IE8 Developer Tool
I have tried to use mshtml.HTMLDocuemntClass but failed
Wizard has url but unable to grab it by url
Unable to grab it by using ie.Form
Please HELP !!!
Thankx in Advance
Is the wizard held in an update panel or anything that is AJAX enabled? if this is then WatiN will not realise that the page has actually refreshed and will therefore not be able to find some of the elements it is looking for
Paul

Winform usercontrol in WebForm

I want to display a "folderview" which I can drag and drop files into but via WebForm. I am doing this via a webbrowser control pointing at local drive. The code works in a win form user control but what I want is to embed this control in web form. This is an intranet so security etc is less of an issue. However when I add things like AllowDrop or the webbrowser control to my control it stops working - I get the image placeholder which I take to mean an error. Can anyone give me an idea what is wrong or perhaps suggest a different solution.
Hi I figured it out when you deploy a new version of your user control you need to clear the GAC download cache - gacutil /clc but I think versioning your dll may work. I don't think web browser control work at all but I may be wrong. I've managed to drag and drop msg files with Outlook Automation see http://bytes.com/groups/net-vb/527320-drag-drop-outlook-vb-net-richtextbox

Resources