C# - Heavily Use Of Watin / IE Stay Open?

Mar 4, 2010

I'm using Watin in C# console app to crawl websites, there are five console app running at the same time.
The reason I partly use Watin as crawler is because a few websites use javascript(or ajax) to set page content.

Following is the sample code to get a page comment count:

Settings.Instance.MakeNewIeInstanceVisible = false;
using (var browser = new IE(commentLink, true))
{
browser.Link(Find.ByUrl(commentLink)).WaitUntilExists(20);
Span commentSpan = browser.Span("COUNT_TOTAL");
if (commentSpan.Exists)
{
int commentCount;
if (Int32.TryParse(commentSpan.InnerHtml, out commentCount))
{
return commentCount;
}
}
}

My problem is after running these 5 console app for a while (90 min), a lot of IE instances are stayed open (because of timeout or error or IE is busy), so the system is quite slow and need to reboot. How do I change my code to prevent this thing happen and make my apps stay effecient?

View 1 Replies


Similar Messages:

WatiN FileUpload Press Open Button To Fast?

Feb 21, 2011

I have the Problem with the File Upload window. When I used it the first time it works perfect but when I call the same functionality to open and upload a File the open button (in the "Choose File to Upload" Dialog) is pressed to fast. So the Test can not write the complete path of the File over set and so the I can not open the File. The Source Code of the function:

public void OpenFileDialogAndUploadCsvFileWithName(string fileName, IE editPage)
{
var fileUploadDialog = editPage.HtmlDialog(Find.ByTitle(PageTitle));
fileUploadDialog.WaitForComplete();
FileUpload fileUpload = fileUploadDialog.FileUpload(Find.ById(new Regex("_FileUpload")));
fileUpload.Set(fileName);
Image image = fileUploadDialog.Image(Find.BySrc(new Regex("/icons/upload.png")));
Element parentElement = image.Parent;
parentElement.FireEventNoWait("onmouseup");
parentElement.FireEventNoWait("onmousedown");
}

The Upload File Dialog is open from Internet Explorer Modal Dialog Window.

View 1 Replies

Best Placement For Javascript In MVC App That Heavily Uses Partial Views?

Apr 24, 2010

What is the best place for javascript that is specific to a partial view? For example, if I have a partial view (loaded via ajax call) with some divs and I want to turn those divs into an accordian, would it be better put the $("#section").accordion() in script tags inside of the partial view, or in a .js file in the function that retrieves that partial view and inserts it into the DOM?

Obviously, common methods I will be keeping in a .js file, however I am more talking about javascript very specific to the partial view itself. Most things I find on the net seem to say to put all javascript into a separate .js but nothing addresses the idea of partial views.

View 1 Replies

C# - How To Test A JQuery UI Dialog Using WatiN

Mar 16, 2010

I can't seem to get a hold of it!

First attempt failed:

string url = "http://jquery_ui_dialog.aspx";
IE jQueryDialog = IE.AttachTo<IE>(Find.ByUrl(url));


Second attempt failed:

Process[] processes = Process.GetProcessesByName("iexplore");
foreach (Process p in processes)
{
if (p.MainWindowTitle == url + " - Microsoft Internet Explorer")
{
// this doesn't find it.
}
}

3rd tries the charm?

View 1 Replies

Verifying Binary Content With WatiN?

Dec 14, 2010

I'm testing a site that serves up some binary (i.e. non-HTML) content. Some links directly deliver custom images, other links custom PDF's.

I'm building test cases in WatiN and NUnit. Wondering if there's a way, using WatiN to get it load a page and then get the byte[] contents of that page.

Currently, I'm just launching a WebClient to grab the content, rather than through WatiN but that's more untested code in my test suite.

View 1 Replies

WatiN - How To Handle Auto Complete Popup

Mar 16, 2010

We're having an intermittent problem that occurs when running certain integration tests on our continuious integration server..

For some reason, every now and then, we get an autocomplete popup that causes a timeout and ultimately a build failure. Is there an eloquent way to detect the popup and click through it?

View 1 Replies

Write A Few Web Tests (over WatiN/Selenium + CassiniDev Web Server) For .net Web Application?

Jan 15, 2011

I want to write a few web tests (over WatiN/Selenium + CassiniDev web server) for my asp.net web application.Problem I encountered is that I dont know what to do in such situations: there is a page where user can click the button to call some third-party service. In my web test i want to create mock of this service, which will always return static value (some value in these test case and other value in other test case).How can i do that?

Currently i use IoC/DI container Microsoft Unity. And my pages gets his dependencies in a manner described in http://msdn.microsoft.com/en-us/library/ff664622%28v=pandp.50%29.aspx.

The only solution that comes to my head is: place all dependencies in web.config for each test case and copy necessary web.config on SetUp of test.

View 1 Replies

JQuery Form Submit Handler Doesn't Trigger When TextField Changes By Watin In MVC App?

Aug 20, 2010

I am writing Watin test in MVC Asp.net app. I mvc app, all input are wrpped with form and every time an input or textarea is changed their form gets submitted by jquery like code below:

$("textarea", context).change(function() {
$(this).parents('form:first').submit();
});

This is perfect when changes are done by keyboard. However this doesn't trigger the form submit when input/textarea are changed by Watin TypeText() method. I tried to call Change() and Blur() events by Watin and also tried PressTab() with no luck.

View 1 Replies

C# - How To Stay Away From DataSets, And What Are The Alternatives

Jan 25, 2010

I found an interesting discussion here:

[URL]

Quote:

DataSets are sub-par amateur solutions to code your Data layer...Stop Using Them and learn to CODE! :)

What is your opinion of DataSets vs. just stubbing out custom classes and working with those? What are other alternatives?

View 3 Replies

C# -global Session Which Will Stay Active?

Aug 19, 2010

i want to create a global session which will stay active until and unless we manually kill it.how to do this in asp.net with c# what i am doing is

HttpContext.Current.Session["UserID"] = someValue;

but in this way the session is lost after some time.

View 4 Replies

C# - How To Simulate Http Request Using WatiN With Specific HTTP Referrer And Query String

Dec 6, 2010

When I use WatiN to go to a specific web page, how can I fake the HTTP referrer with a query string (i.e. request is from google search with query string q=search_term)? So I can verify that the response header has the 301 redirect for specific referrer URL.

View 2 Replies

VS 2008 How To Stay On The Same Page And Fill In The Textboxes

Mar 24, 2011

I am using a gridview as a dropdown extender for a textbox which works nice. I want to select a row in the gridview and fill in some textboxes with data from that row. I know how to do the Attributes.Add for cells in the RowDatabound event. But I have always passed the cell data to another page as parameters. How can I stay on the same page and fill in the textboxes?

Do I setup a javascript and pass the parameters to it and have it fill in the textboxes? I have other texboxes that the user has entered and need to keep that data there.

View 2 Replies

Web Forms :: Cursor Stay Down When I Click Submitbutton?

May 15, 2010

i have textbox and submitbutton at bottom of aspx page when i click submitbutton cursor moving to top of the page, actually i want cursor stay down

View 4 Replies

Web Forms :: Error Happen When Stay On Page For A While

Feb 27, 2014

I have view.aspx page that when I open page and don't do  any thing in this page i.e for 10 minutes when I come back to this page  after 10 minutes and click on hyperlink or button below error happen. Why this error happen?

View 1 Replies

Watin - Settings.FindByDefaultFactory - Doesn't Seem To Use Custom FindByDefaultFactory?

Aug 25, 2010

Based on this article, I've written a custom class which implements the Watin.Core.interfaces.IFindByDefaultFactory, but I don't think I'm correctly assigning it to the watin settings, because it is never used.

Basically, Where/when should I assign to the Settings.FindByDefaultFactory? I've tried in my test Setup, and the text fixture's constructor, but neither seem to cause my custom class to be used. The tests still run and work, but I have to use the full asp.net ID's.

I'm using Watin 2.0.15.928 in VS2008 from nUnit 2.5.2.9222. I am running visual studio as administrator, and tests run sucessfully as long as I don't rely on my custom find logic.

Here's what the start of my text fixture looks like, where I set the FindByDefaultFactory
namespace Fundsmith.Web.Main.BrowserTests
{
[TestFixture]
class WatinHomepageTests
{
private IE _ie;
[SetUp]
public void Setup()
{
Settings.FindByDefaultFactory = new FindByAspIdFactory();
_ie = new IE("http://localhost/somepage.aspx");
}
//etc etc...

And this is what my custom Find By Default factory looks like (simplified), unfortunately, it's never called.

using System.Text.RegularExpressions;
using WatiN.Core;
using WatiN.Core.Constraints;
using WatiN.Core.Interfaces;
namespace Fundsmith.Web.Main.BrowserTests
{
public class FindByAspIdFactory : IFindByDefaultFactory
{
public Constraint ByDefault(string value)
{
// This code is never called :(
// My custom find by id code to cope with asp.net webforms ids...
return Find.ById(value);
}
public Constraint ByDefault(Regex value)
{
return Find.ById(value);
}
}
}

Edit: Extra information after the fact. Based on me fuguring this out, (see answer below), It turns out that the way I was consuming Watin to find the elements was wrong. I was explicitly calling Find.ById, rather than letting the default action occur. So I'd reassigned the default but was then failing to use it!

[Test]
public void StepOneFromHomepageShouldRedirectToStepTwo()
{
_ie.TextField(Find.ById("textBoxId")).TypeText("100");
//Other test stuff...
}

View 1 Replies

When Click Refresh, Div Tags Stay Visible Through The Postback?

Dec 16, 2010

I'm trying to make a div tag retain its state through postback. here's my code

Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html>
[code]...

Now if you click the "toggle" button div tag id sub3 will display. If you click different button div tag blah will display.If you click refresh then both the toggle and different div tags disappear. Is there a way so that when you click refresh that the both div tags stay visible through the postback?

View 15 Replies

How To Make Modal Popup Window To Stay Visible

Apr 1, 2010

I have a popup window of course through the use of modalpopup extender that searches a record. In the popup window, I have two buttons - a search and a close button. Whenever, I click on the search buttton, the popup window immediately disappear. How am be able to make my modal popup window to stay visible even I click on the search button?

View 2 Replies

AJAX :: How To Make ModalPopupExtender Stay In Each UpdatePanel Refresh

Nov 1, 2010

I have a Gridview which is inside a Updatepanel which is updated through a Timer Control every 5 seconds.
So every 5 seconds I get new data in the rows. I am facing an issue in which I want to display the whole mult-line content of my Textbox(es).It displays fine but the modal window disappears after the UpdatePanel is updated.

How do I display this pop-up modal window and make it stay while the UpdatePanel continues to update the rows in the background?

Here is part of my code:

[Code]....

View 15 Replies

Web Forms :: Calender Doesn't Stay On The Screen While Using DatePicker Control

Aug 9, 2010

I've a dataentry screen where I've to give the users aprovision to enter date and for doing that I've used a DatePicker control. The problem is when I'm clicking on the next/prev button to change the month of the calender, the calender is not staying on the screen. So in order to select other month the user has to re click on the button. find below the stepwise description of the problem I'm facing.

1. I click on the calender icon and the calender popps up.

2. Now user tries to navigate months (i.e June to July or June to May) using Next/Prev button of the Calender Control.

3. When Navigating from current month to next/prev month I want the calender to be shown on the screen but actually on click of the Next/Prev button one postback is happening hence I'm loosing the calender from the screen as the calender is loaded again.

4. I'm getting the selected date using onselectedChange event handler.

5. The users will have to click the button again if he wants to navigate to another month.

Is there any way to keep the calender on the screen during the month got changed.

View 4 Replies

Forms Data Controls :: Scrollable/ Keep The Header Stay In The Same Position

Mar 7, 2011

I lost the links that someone posted me how to make the gridview to have scroll bars.

I restate my question:I have a gridview to show about 20 records. Now put the gridview into a <DIV>.

Would like to know how do I make it scrollable but keep the header stay in the same position?There is a header for columns in my gridview.

View 5 Replies

Forms Data Controls :: How To Set FormView To Stay With Last Selected Value After Inserting

Feb 10, 2010

I have a FormView in default insert mode.

When I inserted item to database, the Form refresh and return to all blank or standard selection.
What can I do if I want it keeps the last entered value after inserting record ?

I need this because there are many items to insert and only partial fields need changes from last entered records.

View 3 Replies

Floating Menu - Div Tag Stay In One Position With Relation To The Screen Size

Mar 30, 2010

Although there are a number of floating menu tuts out there, I can't seem to find one that will simply let a div tag stay in one position with relation to the screen size. I have a div tag in the middle right of my page that must basically stay there even if the user scroll down.

View 1 Replies

AJAX :: ModalPopupExtender Won't Stay Popped Up During A Nested Updatepanel Update

Apr 13, 2010

I know I'm missing some simple little thing here...

[code]....

(I put in an Exit Sub at the very top so I'm sure it's not the code).

Essentially, everything is working just great except I need the modal popup to close only if the form data is correct and I choose to close it. The UpdatePanel, "UpdateInfo", is in place to allow form processing without interfering with the UpdatePanel, "UpdatePopup". In my real code, I have a hidden label that I use to report errors. The UpdateInfo is vital for showing/hiding the error but the popup must remain showing...and modal. (I had something like it working once before but I've re-written it since
and just can't remember how to do it.)

This can be viewed at [URL].

[code]....

View 2 Replies

Web Forms :: Want Html Table To Stay In Screen When Scroll Page

May 5, 2010

I have a HTML table in a webpage of an ASP.NET website.

I want this table to stay in the screen when I scroll the page.in fact it's like a toolbox for me and I should always have easy access to it.how should I do that?

View 1 Replies

Keep Target Page Stay In JQuery Thickbox After Post Back?

May 12, 2010

I have an asp.net page "demo.aspx", that has a normal link called "Demo Link" which uses jQuery Thick box. The page that is wrapped inside the Thickbox is "target.aspx", that has a button "Demo Button" and a label.

If I click on the Demo Link, it show the "target.aspx" wrapped inside the Thickbox nicely. However, If I click on the "Demo Button", Thickbox is disappeared, "target.aspx" is not wrapped in Thickbox anymore, it is displayed like a normal asp.net page.

Here's the mark-up code of demo.aspx:

<a href="target.aspx?height=600&width=800" class="thickbox" title="">Testing Thickbox with Post-back</a>

Here's the code-behind of target.aspx:

Protected Sub btnDemo_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnDemo.Click
lblDemo.Text = "Hello World!"
End Sub

How do I keep target.aspx in the Thickbox after the post-back of itself?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved