- pushpendraActive particpant
- Posts : 23
Join date : 2011-09-26
Selenium with Java
Mon Sep 26, 2011 6:22 pm
Hi,
I am New to Selenium,
Can any one help me regarding How to use Test Suits generated by Selenium in java code.
Also i want to know how to handle pop ups in Selenium and if i want to follow a particular URL how to do that.
Thanks.
I am New to Selenium,
Can any one help me regarding How to use Test Suits generated by Selenium in java code.
Also i want to know how to handle pop ups in Selenium and if i want to follow a particular URL how to do that.
Thanks.
- include85Regular Participant
- Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily
Re: Selenium with Java
Mon Sep 26, 2011 7:52 pm
You can save test JUnit.
For pop up you can use:
selenium.click("....");
selenium.waitForPopUp("NameWindow", "30000");
selenium.selectWindow("name=NameWindow"); // popUp
selenium.open("...url...");
For pop up you can use:
selenium.click("....");
selenium.waitForPopUp("NameWindow", "30000");
selenium.selectWindow("name=NameWindow"); // popUp
selenium.open("...url...");
- pushpendraActive particpant
- Posts : 23
Join date : 2011-09-26
Re: Selenium with Java
Mon Sep 26, 2011 8:05 pm
Thanks,
My problem is both pop up and main window using the same url location ..
So this gives error "Current window or frame was closed".
My problem is both pop up and main window using the same url location ..
So this gives error "Current window or frame was closed".
- include85Regular Participant
- Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily
Re: Selenium with Java
Mon Sep 26, 2011 8:15 pm
same url....mmmm....but different title!
You can take title in head.
You can take title in head.
- include85Regular Participant
- Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily
Re: Selenium with Java
Mon Sep 26, 2011 8:17 pm
session().close();
session().selectWindow("null");
try:)
session().selectWindow("null");
try:)
- pushpendraActive particpant
- Posts : 23
Join date : 2011-09-26
Re: Selenium with Java
Mon Sep 26, 2011 8:20 pm
Thanks,
when Test Suits Generate by Selenium IDE saved as JUnit test case .. this save it as a class do i need to write any main method to run it. or using some other methods.
when Test Suits Generate by Selenium IDE saved as JUnit test case .. this save it as a class do i need to write any main method to run it. or using some other methods.
- include85Regular Participant
- Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily
Re: Selenium with Java
Mon Sep 26, 2011 8:58 pm
You can save some class that extends a previuos class with parameters setted, for example.
You must import the libraries.
Good work
You must import the libraries.
Good work
- pushpendraActive particpant
- Posts : 23
Join date : 2011-09-26
Re: Selenium with Java
Mon Sep 26, 2011 9:19 pm
can u give me one working example of Junit ...
and do i need to run it same as other java programs
Thanks.
and do i need to run it same as other java programs
Thanks.
- pushpendraActive particpant
- Posts : 23
Join date : 2011-09-26
Re: Selenium with Java
Tue Sep 27, 2011 4:20 pm
hi
selenium.click("....");
selenium.waitForPopUp("NameWindow", "30000");
selenium.selectWindow("name=NameWindow"); // popUp
selenium.open("...url...");
------------------
in this example wat is selenium*
a class object reference or some static variable or WebDriver..
Thanks
selenium.click("....");
selenium.waitForPopUp("NameWindow", "30000");
selenium.selectWindow("name=NameWindow"); // popUp
selenium.open("...url...");
------------------
in this example wat is selenium*
a class object reference or some static variable or WebDriver..
Thanks
- include85Regular Participant
- Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily
Re: Selenium with Java
Tue Sep 27, 2011 5:32 pm
I use session() and import this:
- Code:
import static com.thoughtworks.selenium.grid.tools.ThreadSafeSeleniumSessionStorage.session;
- pushpendraActive particpant
- Posts : 23
Join date : 2011-09-26
Re: Selenium with Java
Fri Sep 30, 2011 4:51 pm
i tried evry thing but nothing is working.
selenium.open("/idit-web/web-framework/login.do");
selenium.type("id=UserName", "aaa");
selenium.type("id=Password", "111");
selenium.click("css=#Login_middle > table > tbody > tr > td");
// selenium.waitForPopUp("_parent", "600000");
http://selenium.selectWindow("_parent");
selenium.waitForPopUp("newWin1317365228821", "60000");
selenium.windowFocus("newWin1317365228821");
http://System.out.println(selenium.getTitle());
selenium.selectWindow("name=newWin1317365228821");
// System.out.println(selenium.getTitle());
selenium.click("id=NewContactNewGenFromMenu_Link");
selenium.waitForPageToLoad("80000");
selenium.click("id=LastName");
selenium.type("id=LastName", "test");
this is what i am trying ....
Thanks
selenium.open("/idit-web/web-framework/login.do");
selenium.type("id=UserName", "aaa");
selenium.type("id=Password", "111");
selenium.click("css=#Login_middle > table > tbody > tr > td");
// selenium.waitForPopUp("_parent", "600000");
http://selenium.selectWindow("_parent");
selenium.waitForPopUp("newWin1317365228821", "60000");
selenium.windowFocus("newWin1317365228821");
http://System.out.println(selenium.getTitle());
selenium.selectWindow("name=newWin1317365228821");
// System.out.println(selenium.getTitle());
selenium.click("id=NewContactNewGenFromMenu_Link");
selenium.waitForPageToLoad("80000");
selenium.click("id=LastName");
selenium.type("id=LastName", "test");
this is what i am trying ....
Thanks
- include85Regular Participant
- Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily
Re: Selenium with Java
Fri Sep 30, 2011 7:54 pm
newWin1317365228821 ??
Strange name?
Are you sure that does not change the name every refresh?
Strange name?
Are you sure that does not change the name every refresh?
- pushpendraActive particpant
- Posts : 23
Join date : 2011-09-26
Re: Selenium with Java
Fri Sep 30, 2011 8:01 pm
i used Selenium IDE to generate Test case.
Then i export it as Junit test case RC ...
in that code it is showing me like this ...
selenium.waitForPopUp("newWin1317365228821", "60000");
selenium.windowFocus("newWin1317365228821"); ...
and if i use selenium.windowFocus("newWin1317365228821");
it says focused window is closed.
Thanks
Then i export it as Junit test case RC ...
in that code it is showing me like this ...
selenium.waitForPopUp("newWin1317365228821", "60000");
selenium.windowFocus("newWin1317365228821"); ...
and if i use selenium.windowFocus("newWin1317365228821");
it says focused window is closed.
Thanks
- include85Regular Participant
- Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily
Re: Selenium with Java
Fri Sep 30, 2011 9:57 pm
I use this:
- Code:
session().click("button");
session().waitForPopUp(name_windowPopUp, "30000");
Thread.currentThread().sleep(1000);
session().selectWindow("name="+name_windowPopUp);
//code
//close window popup
session().close();
Thread.currentThread().sleep(2000);
session().selectWindow("name_window_parent");
- pushpendraActive particpant
- Posts : 23
Join date : 2011-09-26
Re: Selenium with Java
Wed Oct 05, 2011 1:57 pm
Hey Buddy Thanks for your help.
I am able to run it..
Cheers
I am able to run it..
Cheers
- include85Regular Participant
- Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily
Re: Selenium with Java
Wed Oct 05, 2011 2:26 pm
Great stuff!!
- pushpendraActive particpant
- Posts : 23
Join date : 2011-09-26
Re: Selenium with Java
Tue Oct 18, 2011 5:00 pm
Hi,
Thanks for your earlier help.
I have one more problem
I want to take screenshot if error occurs.
File file=((TakesScreenshot)driver).getScreenshotAs(org.openqa.selenium.OutputType.FILE);
FileUtils.copyFile(file, new File("c:\\outputResult\\"+date.getDate()+"_"+date.getMinutes()+"_"+date.getSeconds()+"screenshot.png"));
i tried this code but as it uses driver and i am using selenium.
is there any alternate ways to take screenshot.
Thanks.
Thanks for your earlier help.
I have one more problem
I want to take screenshot if error occurs.
File file=((TakesScreenshot)driver).getScreenshotAs(org.openqa.selenium.OutputType.FILE);
FileUtils.copyFile(file, new File("c:\\outputResult\\"+date.getDate()+"_"+date.getMinutes()+"_"+date.getSeconds()+"screenshot.png"));
i tried this code but as it uses driver and i am using selenium.
is there any alternate ways to take screenshot.
Thanks.
- include85Regular Participant
- Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily
Re: Selenium with Java
Tue Oct 18, 2011 7:16 pm
- Code:
public void onTestFailure(ITestResult result) {
File file = new File("/s:/screenshots");
Reporter.setCurrentTestResult(result);
Date t = new Date(result.getStartMillis());
String fileName= Integer.toString(t.getYear()) + Integer.toString(t.getMonth()) + Integer.toString(t.getDate()) + Integer.toString(t.getHours()) + Integer.toString(t.getMinutes()) + Integer.toString(t.getSeconds()) + ".png";
String filePath = file.getAbsolutePath() + "/" + result.getMethod() + "/" + fileName;
System.out.println("Writing screen shot to: " + filePath);
Reporter.log("screenshot saved at " + filePath);
Reporter.log("<a href='/userContent/selenium/screenshots/" + result.getMethod() + "/" + fileName + "' height='100' width='100'/>View Screenshot</a>");
session().windowMaximize();
session().captureScreenshot(filePath);
Reporter.setCurrentTestResult(null);
}
I do so!
I hope to help you!!
- pushpendraActive particpant
- Posts : 23
Join date : 2011-09-26
Re: Selenium with Java
Tue Oct 18, 2011 7:35 pm
session().captureScreenshot() method of which Selenium version jar file becase i am not able to find this method
Thanks
Thanks
- include85Regular Participant
- Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily
Re: Selenium with Java
Tue Oct 18, 2011 9:10 pm
selenium-server-standalone-2.0.0.jar
- pushpendraActive particpant
- Posts : 23
Join date : 2011-09-26
Re: Selenium with Java
Mon Nov 07, 2011 5:13 pm
Hi,
can you tell me something about Reporter .
Reporter.log()
Thanks
can you tell me something about Reporter .
Reporter.log()
Thanks
- pushpendraActive particpant
- Posts : 23
Join date : 2011-09-26
Re: Selenium with Java
Thu Nov 24, 2011 7:36 pm
hey.
I need to handle java script validation pop up .
and i have used getAlert() which is not working.
As i can understand validation is part of java script.
so do i need to do something special.
Thanks
I need to handle java script validation pop up .
and i have used getAlert() which is not working.
As i can understand validation is part of java script.
so do i need to do something special.
Thanks
- pushpendraActive particpant
- Posts : 23
Join date : 2011-09-26
Re: Selenium with Java
Thu Nov 24, 2011 7:43 pm
i have tried getAllWindoNames() and getAllWindowTitles() as well to capture alert box.
i want to check this in IE.
Thanks
i want to check this in IE.
Thanks
- pushpendraActive particpant
- Posts : 23
Join date : 2011-09-26
Re: Selenium with Java
Thu Nov 24, 2011 7:44 pm
can i use selenium server log for logging in log file
Permissions in this forum:
You cannot reply to topics in this forum