0

I am trying to login to our product site , say ,site.com, using username "user" and password "pass",using selenium . There are two problems I am facing :

  1. Each time selenium opens the site, it asks me to confirm the security exception ( even though I ask it to store it permanently).

  2. Once the user and password are entered, it gives me an "invalid reference to login page" error . Tomcat gives it actually.

Code is below:

package com.beginning;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestCase;

@SuppressWarnings("deprecation")
public class first extends SeleneseTestCase {

    @Before
    public void setUp() throws Exception {
        selenium = new DefaultSelenium("localhost", 4444, "*firefox", <website name>);
        selenium.start();

    }

    @Test
    public void testJw() throws Exception {
        selenium.open(<login link>);
        selenium.type("name=j_username", user);
        selenium.type("name=j_password", pass);
        selenium.click("css=input[type=\"submit\"]");
        selenium.waitForPageToLoad("30000");
        //selenium.click("link=Sign out");
        //selenium.waitForPageToLoad("30000");
    }

    @After
    public void tearDown() throws Exception {
        selenium.stop();
    }
}
crazyaboutliv
  • 3,029
  • 9
  • 33
  • 50

1 Answers1

1

Selenium is creating a new Firefox profile each time, so it doesn't remember the exemption. Look here Starting Selenium with custom Firefox profile from Eclipse for how to use the same custom profile each time.

Not sure about your second problem but you should use Selenium 2.0 rather than the old 1.0 API.

Community
  • 1
  • 1
artbristol
  • 32,010
  • 5
  • 70
  • 103
  • Thanks. I was under the impression I downloaded the latest from the site :( will cross-check – crazyaboutliv Oct 04 '11 at 08:48
  • I am using selenium 2.7.0 . I guess I wrote code that adheres to selenium 1.0 and not 2 . – crazyaboutliv Oct 04 '11 at 08:49
  • @crazyaboutliv: You're using the Selenium RC API, which is still supported in Selenium 2.x. artbristol is referring to the WebDriver API, which didn't exist in Selenium 1.x. What you're doing is still just fine. – Ross Patterson Oct 04 '11 at 12:51
  • I took care of the profile problem, but the invalid reference part still exists :( What could be the issue ? – crazyaboutliv Oct 05 '11 at 13:01