Selenium Issues

This forum is for Selenium specific usage or questions

This is a public Discussion Area  publicRSS

Forums

Recent Discussions

  • Jagannath Balachandran
    Steps to migrate selenium 0.9.2 projects to Selenium 2.0 in...
    Post posted September 27, 2011 by Jagannath Balachandran

    The project created using selenium 0.9.2 in Twist uses the wrapper TwistSelenium. Hence migrating to Selenium 2.0 involves creating TwistSelenium class in the test project.

    Steps to follow:

    1. Create a Selenium 2.0 project
    2. Copy the scenarios folder from the existing sel 0.9.2 project to the newly created Selenium 2.0 project
    3. Copy all the contents under the src folder (implementation) except the twist.properties of the existing sel 0.9.2 project in to the src folder of newly created Selenium 2.0 project.
    4. Create a package com.thoughtworks.twist.driver.selenium under src folder in the newly created Selenium 2.0 project
    5. Copy the attached TwistSelenium.java and TwistSeleniumFactory.java into com.thoughtworks.twist.driver.selenium package of src folder in the newly created Selenium 2.0 project
    6. Replace applicationContext-Suite.xml with the one attached to the newly created Selenium 2.0 project
    7. Add selenium.browserURL property and value from the twist.properties in selenium 0.9.2 project to the twist.properties in newly created Selenium 2.0 project

    Note -

    1. If you have any additional libraries/spring beans/properties file added in the existing selenium 0.9.2 project , you need to add them to newly created Selenium 2.0 project
    2. If you want to use Selenium 2(webdriver) API’s in the existing fixtures of the newly created project , you need to add a parameter browser of type WebDriver to the fixture constructor and set it to a field named browser. For eg. if there is a fixture called “Shopping Cart”, its constructor would look like

    public ShoppingCart(TwistSelenium selenium, ... ) {

    this.selenium = selenium;

    .....

    ...

    }

    should be changed to

    public ShoppingCart(TwistSelenium selenium, ... , WebDriver browser) {

    this.selenium = selenium;

    .....

    ...

    this.browser = browser;

    }

    Limitations

    1. There are custom api’s that are available as part of selenium 0.9.2 in Twist, which will no longer be valid for Selenium 2.0. If the existing selenium 0.9.2 project uses any of those APIs (provided in the attached depricated_apis.txt file), they need to re-implemented.
    2. Selenium 2.0 does not support all the Selenium 0.9.2 apis(for eg. all drag and drop apis) , it throws UnsupportedOperationException while execution. The workaround is to re-record the corresponding steps using Selenium 2 recorder that is available in Twist
  • Jagannath Balachandran
    Running Twist tests in Selenium 2 Grid
    Post posted September 2, 2011 by Jagannath Balachandran

    Currently Twist does not provide out of the box support to run webdriver tests using Selenium 2 Grid. Follow the instructions below to run Twist tests in Selenium 2 Grid.

    1. Add the attached file CustomWebdriverFactory.java in the "src" folder of the Twist Project (with Selenium 2 as driver) in package com.thoughtworks.twist.driver.webdriver.
    2. Replace applicationContext-suite.xml file in the "src" folder with the file attached.
    3. Add a property in twist.properties located in "src" folder
    webdriver.grid.server=http://localhost:4444/wd/hub
    4. Export the ant build file for the project and add the twist target. Change the number of threads to 2 or more in the Twist target "execute-scenarios". Checkout "http://www.thoughtworks-studios.com/twist-agile-test-automation/2.3.1/help/how_do_i_run_scenarios_from_ant.html#using_ant_integration" to export ant build file for a Twist project.
    5. Export the Twist libraries for the project (Scenarios View-> Right click on the project->Export Twist Libraries) to a particular location.
    6. check "http://code.google.com/p/selenium/wiki/Grid2' to run the hub and the "Selenium Webdriver" nodes
    - Use the selenium-server-standalone-***.jar that is available in exported Twist library folder to run the commands
    7. Go to Config GUI in Twist and set browser to Firefox
    8. Run the build target "execute-scenarios" in build.xml from Twist IDE

    This will start as many firefox browsers as you have mentioned in the "execute-scenarios" target (You can only run 5 threads per node by default)

    To run tests in Chrome

    - Set the browser type in Twist Config GUI to chrome
    - Start the Webdriver node like before along with additional argument "webdriver.chrome.driver" which points to Chrome server
    - For e.g.
    java -Dwebdriver.chrome.driver=<pathToChromeServerBinary> -jar selenium-server-standalone-2.3.0.jar -role webdriver -hub http://localhost:4444/grid/register

    <pathToChromeServerBinary> is available under - <exported Twist library folder>/com.thoughtworks.webdriver.recorder_1.0.0.11210/tools

    To run tests in IE

    - Set the browser type in Twist Config GUI to IE
    - Start the Webdriver node like before along with additional arguments browserName and platform for browser option
    - For e.g.
    java -jar selenium-server-standalone-2.3.0.jar -role wd -hub http://localhost:4444/grid/register 5556 -browser browserName="internet explorer",platform=WINDOWS


    - You can only run one instance of IE browser in each node

    Limitations

    Screenshots provided as part of Twist Reporting will not be accurate. You need to rely on stack trace provided by the report to diagnose the script issues.

     

    Cheers,

    Vinay/Nishant/Jagannath

  • Selenium Learner
    Exported Selenium Script Throws Exception3
    Post posted August 30, 2011 by Selenium Learner

    I recorded an action using the Selenium IDE and used the File->Export Test Cases as Python 2 (Remote Control) format.

    I am using Selenium RC 2.3.0

    I then ran the script from command prompt but it throws an exception.

    The exported Python 2 RC code is:

    from selenium import selenium
    import unittest, time, re

    class login(unittest.TestCase):
       def setUp(self):
           self.verificationErrors = []
           self.selenium = selenium("localhost", 4444, "*chrome", "http://
    testServer1/")
           self.selenium.start()

       def test_login(self):
           sel = self.selenium
           sel.open("/WebAccess/login.html")
           sel.type("id=LoginID", "Administrator")
           sel.type("id=Password", "Administrator")
           sel.click("id=login")
           sel.wait_for_page_to_load("30000")
           sel.click("link=Home") # This is where it fails.

       def tearDown(self):
           self.selenium.stop()
           self.assertEqual([], self.verificationErrors)

    if __name__ == "__main__":
       unittest.main()

    At this line - sel.click("link=Home") it fails with the exception

    ======================================================================
    ERROR: test_login (__main__.login)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
     File "C:\Documents and Settings\User\Desktop\login.py", line 16, in
    test_log
    in
       sel.click("link=Home")
     File "C:\Python27\lib\selenium\selenium.py", line 290, in click
       self.do_command("click", [locator,])
     File "C:\Python27\lib\selenium\selenium.py", line 217, in do_command
       raise Exception, data
    Exception: ERROR: Element link=Home not found

    ----------------------------------------------------------------------

    I even tried increasing the 30000 to 60000 but still no help. I can see the page is loaded fully and waiting for a while because of the higher timeout. However when executing this link=Home it fails.

    The HTML code is:

    <div class="links nopreview">
    <span><a class="csiAction" href="/WebAccess/home.html#URL=centric://
    REFLECTION/INSTANCE/_CS_Data/null">Home</a></span>
    <span>&nbsp;•&nbsp;</span>
    <span><span><a class="csiAction" href="/WebAccess/
    home.html#URL=centric://SITEADMIN/_CS_Site">Setup</a>
    </span><span>&nbsp;•&nbsp;</span>
    </span><span><a title="Sign Out" class="csiAction csiActionLink">Sign
    Out</a></span>
    </div>

    The recorded actions using IDE are:

    <tr>
       <td>open</td>
       <td>/WebAccess/login.html</td>
       <td></td>
    </tr>
    <tr>
       <td>type</td>
       <td>id=LoginID</td>
       <td>Administrator</td>
    </tr>
    <tr>
       <td>type</td>
       <td>id=Password</td>
       <td>Administrator</td>
    </tr>
    <tr>
       <td>clickAndWait</td>
       <td>id=login</td>
       <td></td>
    </tr>

    <tr>
       <td>click</td>
       <td>link=Home</td>
       <td></td>
    </tr>

    I did run the test using IDE's recorded script. It works great. I was able to login and click on the Home link too. However, it fails with that exception when I wanted to run it using Python's Unittest with Selenium Server 2.3.0.

    I tried sel.click('//a[contains(text((),"Home")]') and it throws the exception

    Traceback (most recent call last): File "C:\Documents and Settings\User\Desktop\login.py", line 17, in test_log in sel.click('//a[contains(text((),"Home")]') File "C:\Python27\lib\selenium\selenium.py", line 290, in click self.do_command("click", [locator,])
    File "C:\Python27\lib\selenium\selenium.py", line 217, in do_command raise Exception, data Exception:
    ERROR: Invalid xpath [2]: //a[contains(text((),"Home")]

    I even tried sel.click('xpath=//a[contains(text((),"Home")]') and it still throws the same exception as mentioned in the above comment. I wonder what could be wrong. If I comment the line that clicks on the Home link then it runs fine. Its the problem with clicking this link.

    To add, not only for Home. It does not work for Home or Setup or even Signout for that matter. It does not work for any of the links in that div. However playing back the recorded script works fine!

    Any suggestions or guidance, please?

  • anotherdave
    Screenshots on Test FailAnswered2
    Post posted May 11, 2011 by anotherdave

    Hello,

    Possibly more of a Selenium issue than a Twist issue, so thought it best to post here.

    I'm looking to take a screenshot of the browser whenever a test fails. I have them up & running fine for each test, but it will fill up space very fast to constantly take screenshots of passing test steps.

    Anyone have any advice on how I should go about this?

  • Alexey Litosh
    How to run scenarios in different browsers?3
    Post posted April 27, 2011 by Alexey Litosh

    Hi,

    Could you please tell me how to run in different browthers scenarios which were recorded by twist using selenium driver and firefox?

    Thanks a lot!

Recent Comments

Recent Partcipants

  • angshuman
  • Mansi Shah
  • Andy Kemp
  • Jagannath Balachandran
  • Selenium Learner
  • anotherdave
  • Ketan Padegaonkar
  • Vinay Dayananda
  • Ananth
  • tester26.tester
  • Alexey Litosh
  • Nivetha
  • Manish Chakravarty
  • Gopi
  • Thrivikram Nag
  • Preeti
  • James O'Sullivan
  • Govind
  • Geetha Shimoga
  • Bogdan Gusiev

Welcome Guest

Log in if you have an account.

Otherwise, register for an account.

For more details, please visit the How This Site Works page.

Search this Space

Keyword Search