Selenium waitforpopup


How to stop the selenium server until a popup opens?
We have selenium.waitForPageToLoad to stop the server until the Page Loads. But is there any way to stop it for Popup?
If you are dealing with a direct popup then You can use 
selenium.WaitForPopUp("id=popup_container", "30000");

to stop the server until popup Opens. 

But what will you do if your popup is a div tag like seen in this  DEMO?


If your 'popup' is not actually a popup, it's just a div tag. So you have to wait until that element (div tag) is present. There is a method to check if the element is present:
selenium.IsElementPresent("div_id_of_the_popup");
This is the way to stop the selenium server until a div_popup Opens.
Read more...

Press Enter Key in Selenium

If you are working with a SearchBox using Selenium. In which you have to type something and you have to press Enter to search. You can do it in the following way...


// this sends an Enter to the element

selenium.type("locator", Keys.ENTER);


// The below code sends the "Any text" and then confirms it with Enter

selenium.type("locator", "Any text" + Keys.ENTER);


Here locator means You have to add the TextBox's Id.  

or try this


selenium.KeyPressNative("13");

or


selenium.keyDown("locator of element", "\\13");

Where 13 is the ASCII value of Enter Key.. 

Hope this may help you.
Read more...

Sending email with attachments from C#


In many cases you may required to send emails using ASP.NET. You can have all the classes required to send an email in the System.Net.Mail namespace. You can send an email from ASP.NET as follows :

First you have to add these namespaces to your code behind file:

1. using System.Net;
2. using System.Net.Mail;

Then write the following method

public void email_send()
{
    MailMessage mail = new MailMessage();
    SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
    mail.From = new MailAddress("your mail@gmail.com");
    mail.To.Add("to_mail@gmail.com");
    mail.Subject = "Test Mail - 1";
    mail.Body = "mail with attachment";

    System.Net.Mail.Attachment attachment;
    attachment = new System.Net.Mail.Attachment("c:/textfile.txt");
    mail.Attachments.Add(attachment);

    SmtpServer.Port = 587;
    SmtpServer.Credentials = new System.Net.NetworkCredential("your mail@gmail.com", "your password");
    SmtpServer.EnableSsl = true;

    SmtpServer.Send(mail);

}

Using the above you can send attachemebts also. Hope this helps :-)
Read more...

No connection could be made because the target machine actively refused it 127.0.0.1:4444

I had this issue and it took a lot of time to find the solution for this. I searched many sites for the solutions. After few hours, i have found the solution for this issue. (This is the solution which worked for me . I hope this will work for others also.)

The problem is i din't start the selenium server. After starting the server, issue gone and all worked fine.

You can download selenium server here. Download Selenium server

After downloading start the selenium server. See screen shot below


Read more...