Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» FlexMonkium Download Not available under Gorillalogic site
Thu Dec 08, 2016 5:40 pm by bhanu.praveen

» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Selenium with Java

View previous topic View next topic Go down

Selenium with Java

Post by pushpendra on 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.

pushpendra
Active particpant
Active particpant

Posts : 23
Join date : 2011-09-26

Back to top Go down

Re: Selenium with Java

Post by include85 on 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

include85
Regular Participant
Regular Participant

Posts : 27
Join date : 2011-09-22
Age : 31
Location : Italia, Sicily

Back to top Go down

Re: Selenium with Java

Post by pushpendra on 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".

pushpendra
Active particpant
Active particpant

Posts : 23
Join date : 2011-09-26

Back to top Go down

Re: Selenium with Java

Post by include85 on Mon Sep 26, 2011 8:15 pm

same url....mmmm....but different title!Wink
You can take title in head.

include85
Regular Participant
Regular Participant

Posts : 27
Join date : 2011-09-22
Age : 31
Location : Italia, Sicily

Back to top Go down

Re: Selenium with Java

Post by include85 on Mon Sep 26, 2011 8:17 pm

session().close();
session().selectWindow("null");

try:)

include85
Regular Participant
Regular Participant

Posts : 27
Join date : 2011-09-22
Age : 31
Location : Italia, Sicily

Back to top Go down

Re: Selenium with Java

Post by pushpendra on 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.

pushpendra
Active particpant
Active particpant

Posts : 23
Join date : 2011-09-26

Back to top Go down

Re: Selenium with Java

Post by include85 on 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

include85
Regular Participant
Regular Participant

Posts : 27
Join date : 2011-09-22
Age : 31
Location : Italia, Sicily

Back to top Go down

Re: Selenium with Java

Post by pushpendra on 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
Active particpant
Active particpant

Posts : 23
Join date : 2011-09-26

Back to top Go down

Re: Selenium with Java

Post by pushpendra on 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

pushpendra
Active particpant
Active particpant

Posts : 23
Join date : 2011-09-26

Back to top Go down

Re: Selenium with Java

Post by include85 on 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?

include85
Regular Participant
Regular Participant

Posts : 27
Join date : 2011-09-22
Age : 31
Location : Italia, Sicily

Back to top Go down

Re: Selenium with Java

Post by pushpendra on 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

pushpendra
Active particpant
Active particpant

Posts : 23
Join date : 2011-09-26

Back to top Go down

Re: Selenium with Java

Post by include85 on Fri Sep 30, 2011 7:54 pm

newWin1317365228821 ??

Strange name?
Are you sure that does not change the name every refresh?

include85
Regular Participant
Regular Participant

Posts : 27
Join date : 2011-09-22
Age : 31
Location : Italia, Sicily

Back to top Go down

Re: Selenium with Java

Post by pushpendra on 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

pushpendra
Active particpant
Active particpant

Posts : 23
Join date : 2011-09-26

Back to top Go down

Re: Selenium with Java

Post by include85 on 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");

include85
Regular Participant
Regular Participant

Posts : 27
Join date : 2011-09-22
Age : 31
Location : Italia, Sicily

Back to top Go down

Re: Selenium with Java

Post by pushpendra on Wed Oct 05, 2011 1:57 pm

Hey Buddy Thanks for your help.
I am able to run it..


Cheers cheers

pushpendra
Active particpant
Active particpant

Posts : 23
Join date : 2011-09-26

Back to top Go down

Re: Selenium with Java

Post by include85 on Wed Oct 05, 2011 2:26 pm

Great stuff!! cheers

include85
Regular Participant
Regular Participant

Posts : 27
Join date : 2011-09-22
Age : 31
Location : Italia, Sicily

Back to top Go down

Re: Selenium with Java

Post by pushpendra on 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.

pushpendra
Active particpant
Active particpant

Posts : 23
Join date : 2011-09-26

Back to top Go down

Re: Selenium with Java

Post by include85 on 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

include85
Regular Participant
Regular Participant

Posts : 27
Join date : 2011-09-22
Age : 31
Location : Italia, Sicily

Back to top Go down

Re: Selenium with Java

Post by pushpendra on 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

pushpendra
Active particpant
Active particpant

Posts : 23
Join date : 2011-09-26

Back to top Go down

Re: Selenium with Java

Post by include85 on Tue Oct 18, 2011 9:10 pm

selenium-server-standalone-2.0.0.jar

include85
Regular Participant
Regular Participant

Posts : 27
Join date : 2011-09-22
Age : 31
Location : Italia, Sicily

Back to top Go down

Re: Selenium with Java

Post by pushpendra on Mon Nov 07, 2011 5:13 pm

Hi,
can you tell me something about Reporter .
Reporter.log()

Thanks

pushpendra
Active particpant
Active particpant

Posts : 23
Join date : 2011-09-26

Back to top Go down

Re: Selenium with Java

Post by pushpendra on 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
Active particpant
Active particpant

Posts : 23
Join date : 2011-09-26

Back to top Go down

Re: Selenium with Java

Post by pushpendra on 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
Active particpant
Active particpant

Posts : 23
Join date : 2011-09-26

Back to top Go down

Re: Selenium with Java

Post by pushpendra on Thu Nov 24, 2011 7:44 pm

can i use selenium server log for logging in log file

pushpendra
Active particpant
Active particpant

Posts : 23
Join date : 2011-09-26

Back to top Go down

Re: Selenium with Java

Post by Sponsored content Today at 3:52 pm


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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