Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

Suppose I login to evernote.com using Selenium RC. Is it possible for me to change the base_url to google.com while staying on the same page. I do not want to open a new browser for google.com. When I create another instance of Default Selenium for google.com it shows up in a new browser. I would like to find if there is anyway to change the base_url while on the same page.

A portion of my code:

//Declare HttpCommandProcessor and pass selenium object
HttpCommandProcessor proc = new  
HttpCommandProcessor("localhost",4444,"*chrome","http://evernote.com/");

DefaultSelenium sel = new DefaultSelenium(proc);
@Test (dataProvider = "DP1")
public void evernoteSharing(String user1, 
        String password1, 
        String email1, 
        String user2, 
        String password2, 
        String email2
){

    try
    {
        //Call login module and pass Selenium object, username and password as parameters
        loginObj.login(sel, user1, password1);
        //Click on the Try new evernote button in the pop-up window
        sel.click(popupLogin);
        //sel.waitForPageToLoad("30000");
        Assert.assertEquals(sel.getTitle(), homeTitle);

        sel.click(lnkoldEvernote);
        sel.waitForPageToLoad(stimeout);
        sel.open("www.google.com");
        sel.waitForPageToLoad(stimeout);

        //Call create notebook module and pass Selenium object as a variable
        createNb.createNotebook(sel);

        //Call sharing module and pass selenium object and second user's emailid as parameter
        shareObj.shareNoteIndividual(sel, email2);
share|improve this question
    
Would be good to know what version of seleinum you are using (I'm specifically looking for a version number, Selenium RC is one of the Selenium API's that is available in Selenium 1 and Selenium 2) –  Ardesco Apr 3 '12 at 9:36
add comment

1 Answer

You should be able to do so while using browsers with elevated security privileges like *chrome for firefox. So you could just do

selenium.open("newURL");

in your test. Problem of changing URL is, it change in domain and normal Selenium browser mode is restricted by Java Script's Same Origin Policy, as I mentioned above browsers with elevated security privileges should get you going.

I suppose this is the point where you are trying to load another URL in same selenium session -

sel.open("www.google.com");
sel.waitForPageToLoad(stimeout);

First - don't use waitForPageToLoad, open api takes care of it. Now if sel.open does not work then you should definitely encounter error. Don't keep you method in try catch block and see the error you encounter....

share|improve this answer
    
When I use *chrome still it opens up in firefox browser and there was no difference in behavior. –  Aruna May 23 '11 at 16:41
    
*chrome is another wrapper for firefox that can use https. It doesn't mean that it literary will open a CHROME browser. –  Hannibal May 23 '11 at 17:03
    
@Aruna, as Hanninal said *chrome is to deal with domain change in, so first you get your browser launched usual way and then mid way some where in your test you could do selenium.Open("URL") to change the domain –  Tarun May 23 '11 at 17:45
    
I tried these two ways on chrome and did not succeed:1.) selenium.open("www.google.com") did not work in the middle of the code. It proceeded with the next steps on the evernote site 2) I declared another instance of selenium for google and it opened up as a new browser session –  Aruna May 23 '11 at 19:19
    
second method would open a new browser as you declared new instance of Selenium. Is it possible for you to post your code snippet here. Code snippet for method 1 –  Tarun May 24 '11 at 3:16
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.