Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
pushpendra
pushpendra
Active particpant
Active particpant
Posts : 23
Join date : 2011-09-26

Selenium with Java Empty 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.
include85
include85
Regular Participant
Regular Participant
Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily

Selenium with Java Empty 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..."); Wink
pushpendra
pushpendra
Active particpant
Active particpant
Posts : 23
Join date : 2011-09-26

Selenium with Java Empty 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".
include85
include85
Regular Participant
Regular Participant
Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily

Selenium with Java Empty Re: Selenium with Java

Mon Sep 26, 2011 8:15 pm
same url....mmmm....but different title!Wink
You can take title in head.
include85
include85
Regular Participant
Regular Participant
Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily

Selenium with Java Empty Re: Selenium with Java

Mon Sep 26, 2011 8:17 pm
session().close();
session().selectWindow("null");

try:)
pushpendra
pushpendra
Active particpant
Active particpant
Posts : 23
Join date : 2011-09-26

Selenium with Java Empty 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.
include85
include85
Regular Participant
Regular Participant
Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily

Selenium with Java Empty 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 study
pushpendra
pushpendra
Active particpant
Active particpant
Posts : 23
Join date : 2011-09-26

Selenium with Java Empty 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.
pushpendra
pushpendra
Active particpant
Active particpant
Posts : 23
Join date : 2011-09-26

Selenium with Java Empty 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
include85
include85
Regular Participant
Regular Participant
Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily

Selenium with Java Empty 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;
How do you register selenium tests?
pushpendra
pushpendra
Active particpant
Active particpant
Posts : 23
Join date : 2011-09-26

Selenium with Java Empty 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
include85
include85
Regular Participant
Regular Participant
Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily

Selenium with Java Empty 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?
pushpendra
pushpendra
Active particpant
Active particpant
Posts : 23
Join date : 2011-09-26

Selenium with Java Empty 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
include85
include85
Regular Participant
Regular Participant
Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily

Selenium with Java Empty 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");
pushpendra
pushpendra
Active particpant
Active particpant
Posts : 23
Join date : 2011-09-26

Selenium with Java Empty Re: Selenium with Java

Wed Oct 05, 2011 1:57 pm
Hey Buddy Thanks for your help.
I am able to run it..


Cheers cheers
include85
include85
Regular Participant
Regular Participant
Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily

Selenium with Java Empty Re: Selenium with Java

Wed Oct 05, 2011 2:26 pm
Great stuff!! cheers
pushpendra
pushpendra
Active particpant
Active particpant
Posts : 23
Join date : 2011-09-26

Selenium with Java Empty 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.
include85
include85
Regular Participant
Regular Participant
Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily

Selenium with Java Empty 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!!Smile
pushpendra
pushpendra
Active particpant
Active particpant
Posts : 23
Join date : 2011-09-26

Selenium with Java Empty 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
include85
include85
Regular Participant
Regular Participant
Posts : 27
Join date : 2011-09-22
Age : 39
Location : Italia, Sicily

Selenium with Java Empty Re: Selenium with Java

Tue Oct 18, 2011 9:10 pm
selenium-server-standalone-2.0.0.jar
pushpendra
pushpendra
Active particpant
Active particpant
Posts : 23
Join date : 2011-09-26

Selenium with Java Empty Re: Selenium with Java

Mon Nov 07, 2011 5:13 pm
Hi,
can you tell me something about Reporter .
Reporter.log()

Thanks
pushpendra
pushpendra
Active particpant
Active particpant
Posts : 23
Join date : 2011-09-26

Selenium with Java Empty 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
pushpendra
pushpendra
Active particpant
Active particpant
Posts : 23
Join date : 2011-09-26

Selenium with Java Empty 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
pushpendra
pushpendra
Active particpant
Active particpant
Posts : 23
Join date : 2011-09-26

Selenium with Java Empty Re: Selenium with Java

Thu Nov 24, 2011 7:44 pm
can i use selenium server log for logging in log file
Sponsored content

Selenium with Java Empty Re: Selenium with Java

Back to top
Permissions in this forum:
You cannot reply to topics in this forum