Rômulo Spier
Rômulo Spier

Reputation: 231

Using C# to automate a process that involves other website

I have a web application in asp.net 4.0 and at some moment I have to access a link outside my domain and fill it up with some info, log-in, and other stuff like dates. I want to automate this process.

This is what I want:

User clicks on a button, the link to the other site opens on a new tab with the textboxes filled with info from my application. The User informs the captcha and press "Continue". The web-site will validate info and log him in, then there'll be more steps like this when logged in.

What I've tried:

Iframe on my app - Wasn't able to get access to the DOM elements inside of it.

Using javascript - Something like:

var window = window.open("site"); 
window.getElementById(""); 

but still got no success.

And then finnaly I tried Selenium, which is a framework for automating tests and I want to perform tasks, not testing. I got it working with selenium, actually it worked like a charm.

Code:

            var browser = Request.Browser;

            IWebDriver driver = null;
            switch (browser.Browser)
            {
                case "Chrome":
                    driver = new ChromeDriver(Server.MapPath("path"));
                    break;
                default:
                    driver = new FirefoxDriver();
                    break;
            }

            driver.Navigate().GoToUrl("url");

            IWebElement field = driver.FindElement(By.Id("fieldId"));
            field .SendKeys("info i want to send");
            ...

The problem is that I have to publish my app because I have a lot of users using it(that's the main reason I'm trying to automate this process). And when I published it to my local IIS for testing, it stopped working and I don't know what to do or what to search for. Any help would be appreciated, thanks in advance.

Upvotes: 1

Views: 1375

Answers (1)

Rômulo Spier
Rômulo Spier

Reputation: 231

I've managed to find the solution on this quite similar question:

Can we run Selenium WebDriver Test case with IIS, instead of Visual Studio Development server

To make it work, I needed to create start a RemoteWebDriverServer following those 2 steps. You can find more info about it here: Selenium RC info.

Upvotes: 1

Related Questions