In IE

Tools->Internet Options -> security tab :

check Enable Protected Mode
for internet,local intranet, trusted sites,Restricted sites zones.

Use Developer Tools F12 in IE, Firebug for firefox and Inspect Element(Right click) in Chrome
view source
===

for dropdowns

driver.FindElement(By.Id(“txtSearchText”)).SendKeys(“anthony.raj”) ..it wont work

below lines will work :
driver.FindElement(By.Id(“ctl00_ContentPlaceHolder1_rcbDosage_Input”)).Click();
driver.FindElement(By.Id(“ctl00_ContentPlaceHolder1_rcbDosage_Input”)).SendKeys(Keys.Down); //All
driver.FindElement(By.Id(“ctl00_ContentPlaceHolder1_rcbDosage_Input”)).Submit();

—–
for datepickers

in chrome : right click -> inspect element -> choose a date(month,year) -> select copy xpath

driver.FindElement(By.Id(“ctl00_ContentPlaceHolder1_rdateProjectStartDate_CalendarPopupButton”)).Click();
driver.FindElement(By.XPath(“.//*[@id=’ctl00_ContentPlaceHolder1_rdateProjectStartDate_calendar_NP’]/img”)).Click();
driver.FindElement(By.XPath(“.//*[@id=’ctl00_ContentPlaceHolder1_rdateProjectStartDate_calendar_Top’]/tbody/tr[3]/td[2]/a”)).Click();

====

My step:
1. Open page
2. Click on “Apply” button.
3. A child window is opened. I need to check content, click on button on
the child window.

1st sol:

in javascript
you will write code like this

window.open(“UserLookUp.aspx”, ‘userlookup’, ‘toolbar=no,resizable=no,menubar=no,status=no,scrollbars=yes,titlebar=no,top=200,left=400, width=650px, height=300px’);

in the above for window.open we have 3 parameters. 1st is page name,2nd is windowname,
3rd is widht,height etc.

In the below script use the 2nd parameter for driver.SwitchTo().Window(“userlookup”);
System.Threading.Thread.Sleep(4000);
driver.SwitchTo().Window(“userlookup”);

2nd sol :

String parentWindow = driver.getWindowHandle();
Set handles = driver.getWindowHandles();
for(String windowHandle : handles)
{
if(!windowHandle.equals(parentWindow))
{
driver.switchTo().window(windowHandle);

driver.close(); //closing child window
driver.switchTo().window(parentWindow); //cntrl to parent window
}
}

To go back to the main window(default window) .

use driver.switchTo().defaultContent();

Advertisements

About ambatisreedhar

Developer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s