Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Selenium for web testing on IE?

  • 08-10-2013 2:22pm
    #1
    Registered Users, Registered Users 2 Posts: 2,321 ✭✭✭


    Hi,
    Brand new to selenium and was wondering if there is an easy was of running recorded testcases (from firefox) on IE?

    They are just basic .net websites I am testing.

    I have read a couple of things online but finding it hard to follow.
    I have downloaded JDK and windows driver server but not sure what I am supposed to do.

    As its mainly IE we support I need to run the testcases on this.

    Any advice appreciated.
    Sorry if I left any info out.


Comments

  • Registered Users, Registered Users 2 Posts: 599 ✭✭✭ambasite


    I presume you recorded the test cases using Selenium IDE plugin? If so, you can save you test cases as a test suite html file. You can then run this test suite using the Selenium Server against various browsers - IE, Chrome, Firefox.

    Download Selenium Server from here:

    http://selenium.googlecode.com/files/selenium-server-standalone-2.35.0.jar

    To run the test suite against IE from command line:

    java -jar selenium-server-standalone-2.35.0.jar -htmlSuite "*iexplore" "http://baseurl.com" "yourTestSuite.html"


  • Registered Users, Registered Users 2 Posts: 2,321 ✭✭✭sham69


    thanks for the reply.
    I tried this but I got some error about not being able to open something.
    I will do it again and take note of the error.
    Thanks.


  • Registered Users, Registered Users 2 Posts: 599 ✭✭✭ambasite


    Would be interested to see the error you are getting. I haven't used Selenium IDE in a while. The latest version (2.4.0) has the option to run tests against IE & Chrome, using Webdriver Playback feature:

    http://blog.reallysimplethoughts.com/2013/02/18/webdriver-playback-in-selenium-ide-is-here/


  • Registered Users, Registered Users 2 Posts: 2,321 ✭✭✭sham69


    Not getting an error now.
    Its starting fine but when I go to play the tests I am getting an error in the selenium gui (small window) saying that the server is not started , even though it is

    I can see the "standalone server is started message in the command prompt"


  • Closed Accounts Posts: 446 ✭✭Devi


    sham69 wrote: »
    Hi,
    Brand new to selenium and was wondering if there is an easy was of running recorded testcases (from firefox) on IE?

    They are just basic .net websites I am testing.

    I have read a couple of things online but finding it hard to follow.
    I have downloaded JDK and windows driver server but not sure what I am supposed to do.

    As its mainly IE we support I need to run the testcases on this.

    Any advice appreciated.
    Sorry if I left any info out.

    Id recommend recording them in IDE and playing them back with webdriver and eclipse.

    The things you will need are:
    Java JDK
    Eclipse IDE
    Junit Libraries
    Selenium Libraries, Stand alone server and IEDriverServer/ chromedriver

    So you basically record your test on Firefox, export it as a java/Junit file, open it up in an eclipse project with libraries added, then change the setup() method to
     [U].......[/U]
      [U] [/U]
      [U]WebDriver[/U] driver;
       
      @[U]Before[/U]
             [B]public[/B] [B]void[/B] setUp(){
               File file = [B]new[/B] File("Location of chromedriver");       
    System.[I]setProperty[/I]("webdriver.chrome.driver",file.getAbsolutePath());
                    [U]driver[/U] = [B]new[/B] [U]ChromeDriver[/U]();
      [U]driver[/U].manage().timeouts().implicitlyWait(30, TimeUnit.[I]SECONDS[/I]);
      [U]driver[/U].get("[U]Webpage to test[/U]");
             }
      .......
      
    

    Edit: Sorry code indentation went a bit bonkers there but youll get what I mean when you see it.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,321 ✭✭✭sham69


    Devi wrote: »
    Id recommend recording them in IDE and playing them back with webdriver and eclipse.

    The things you will need are:
    Java JDK
    Eclipse IDE
    Junit Libraries
    Selenium Libraries, Stand alone server and IEDriverServer/ chromedriver

    So you basically record your test on Firefox, export it as a java/Junit file, open it up in an eclipse project with libraries added, then change the setup() method to
     [U].......[/U]
      [U] [/U]
      [U]WebDriver[/U] driver;
       
      @[U]Before[/U]
             [B]public[/B] [B]void[/B] setUp(){
               File file = [B]new[/B] File("Location of chromedriver");       
    System.[I]setProperty[/I]("webdriver.chrome.driver",file.getAbsolutePath());
                    [U]driver[/U] = [B]new[/B] [U]ChromeDriver[/U]();
      [U]driver[/U].manage().timeouts().implicitlyWait(30, TimeUnit.[I]SECONDS[/I]);
      [U]driver[/U].get("[U]Webpage to test[/U]");
             }
      .......
      
    

    Edit: Sorry code indentation went a bit bonkers there but youll get what I mean when you see it.



    Thanks,
    I'll give it a go.
    Problem is the time taking to get this setup.
    We mostly do manual testing in work (actually its 99% manual)
    I am trying to introduce some automation and get us up to date.
    Would be good for myself also as I am 8 years manual testing with no exposure to test tools and automation etc.
    Thanks all for the replies.


  • Registered Users, Registered Users 2 Posts: 2,321 ✭✭✭sham69


    Sorry to bring this back up but really struggling with this.

    I can record no problem in Firefox but just can't it to playback in IE
    I was having an issue with protected mode in IE (zones)
    I eventually figured out how to change this in the registry (can't do it via frontend as security have it locked down)

    Now when I try to playback it is asking me to specify webdriver location, which is fine but if I export testcase as java , junit file , it doesnt playback in selenium?

    It will playback in HTML format but you can't seem to edit system properties this way to get it to open in IE.

    When run in selenium as a junit file It gives me an error saying no command found, error loading testcase.

    script here:

    package com.example.tests;

    import java.util.regex.Pattern;
    import java.util.concurrent.TimeUnit;
    import org.junit.*;
    import static org.junit.Assert.*;
    import static org.hamcrest.CoreMatchers.*;
    import org.openqa.selenium.*;
    import org.openqa.selenium.firefox.IEDriver;
    import org.openqa.selenium.support.ui.Select;

    public class PrizebondsTestCase1 {
    private WebDriver driver;
    private String baseUrl;
    private boolean acceptNextAlert = true;
    private StringBuffer verificationErrors = new StringBuffer();

    @Before
    public void setUp() throws Exception {
    driver = new IEDriver(C:\Users\cashionb\Downloads\IEDriverServer.exe);
    baseUrl = "https://www.google.ie/";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    }

    @Test
    public void testgoogleTestCase1() throws Exception {
    driver.get(baseUrl + "/");
    driver.findElement(By.cssSelector("img[alt=\"How to Purchase\"]")).click();
    driver.findElement(By.linkText("Online")).click();
    // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=Standard | ]]
    driver.findElement(By.cssSelector("img[alt=\"Close \"]")).click();
    // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | null | ]]
    driver.findElement(By.name("name1")).clear();
    driver.findElement(By.name("name1")).sendKeys("");
    driver.findElement(By.name("surname1")).clear();
    driver.findElement(By.name("surname1")).sendKeys("");
    driver.findElement(By.name("clubname1")).clear();
    driver.findElement(By.name("clubname1")).sendKeys("");
    driver.findElement(By.name("dob")).clear();
    driver.findElement(By.name("dob")).sendKeys("jkhjkhkjh");
    driver.findElement(By.name("Addr1_Line1")).clear();
    driver.findElement(By.name("Addr1_Line1")).sendKeys("jkhjkh");
    driver.findElement(By.name("Addr1_Line2")).clear();
    driver.findElement(By.name("Addr1_Line2")).sendKeys("jkhjk");
    driver.findElement(By.name("Addr1_Line3")).clear();
    driver.findElement(By.name("Addr1_Line3")).sendKeys("hjkh");
    driver.findElement(By.name("Addr1_Line4")).clear();
    driver.findElement(By.name("Addr1_Line4")).sendKeys("jkhjk");
    new Select(driver.findElement(By.name("Addr1_County"))).selectByVisibleText("Cavan");
    driver.findElement(By.name("email1")).clear();
    driver.findElement(By.name("email1")).sendKeys("");
    driver.findElement(By.name("units")).clear();
    driver.findElement(By.name("units")).sendKeys("4");
    driver.findElement(By.name("terms")).click();
    // ERROR: Caught exception [ERROR: Unsupported command [waitForPopUp | Standard | 30000]]
    // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | name=Standard | ]]
    driver.findElement(By.cssSelector("img[alt=\"I Accept\"]")).click();
    // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | null | ]]
    driver.findElement(By.cssSelector("input[type=\"image\"]")).click();
    driver.findElement(By.cssSelector("input[type=\"image\"]")).click();
    new Select(driver.findElement(By.id("CardType"))).selectByVisibleText("Laser");
    driver.findElement(By.id("cardnumber_txtValue")).clear();
    driver.findElement(By.id("cardnumber_txtValue")).sendKeys("");
    new Select(driver.findElement(By.id("cardexpirymonth"))).selectByVisibleText("");
    new Select(driver.findElement(By.id("cardexpiryyear"))).selectByVisibleText("");
    driver.findElement(By.id("CSC_txtValue")).clear();
    driver.findElement(By.id("CSC_txtValue")).sendKeys("");
    driver.findElement(By.id("CardHolderName_txtValue")).clear();
    driver.findElement(By.id("CardHolderName_txtValue")).sendKeys("");
    driver.findElement(By.id("cbAuthorise")).click();
    driver.findElement(By.id("btnSubmit")).click();
    }

    @After
    public void tearDown() throws Exception {
    driver.quit();
    String verificationErrorString = verificationErrors.toString();
    if (!"".equals(verificationErrorString)) {
    fail(verificationErrorString);
    }
    }

    private boolean isElementPresent(By by) {
    try {
    driver.findElement(by);
    return true;
    } catch (NoSuchElementException e) {
    return false;
    }
    }

    private boolean isAlertPresent() {
    try {
    driver.switchTo().alert();
    return true;
    } catch (NoAlertPresentException e) {
    return false;
    }
    }

    private String closeAlertAndGetItsText() {
    try {
    Alert alert = driver.switchTo().alert();
    String alertText = alert.getText();
    if (acceptNextAlert) {
    alert.accept();
    } else {
    alert.dismiss();
    }
    return alertText;
    } finally {
    acceptNextAlert = true;
    }
    }
    }




    Any advice greatly appreciated.
    I just need to figure out how to playback in IE.
    Surely it can't be that difficult, feeling really stupid :(


  • Registered Users, Registered Users 2 Posts: 2,321 ✭✭✭sham69


    forgot to say, I did edit some sensitive data and also ignore the popup error, I am not concerned about this at the moment and has nothing to do with the playback issue.


    Thanks.

    From the command line.....


    13:07:37.794 WARN - Exception: The path to the driver executable must be set by
    the webdriver.ie.driver system property; for more information, see http://code.g
    oogle.com/p/selenium/wiki/InternetExplorerDriver. The latest version can be down
    loaded from http://code.google.com/p/selenium/downloads/list


  • Registered Users, Registered Users 2 Posts: 2,321 ✭✭✭sham69


    got it sorted.
    Started from scratch again and managed to get it working using this command..

    java -jar selenium-server-standalone-2.35.0.jar -htmlSuite "*iexplore" "http://baseurl.com" "yourTestSuite.html"



    Thanks Ambasite....

    Now to figure out how to use it ;)


Advertisement