Selenium Issues

This forum is for Selenium specific usage or questions

This is a public Discussion Area  publicRSS

Posts

  • 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
  • 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

  • Exported Selenium Script Throws Exception3
    Post last edited February 9, 2012 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?

  • Screenshots on Test FailAnswered2
    Post last edited February 9, 2012 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?

  • How to run scenarios in different browsers?3
    Post last edited February 9, 2012 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!

  • Selenium - Uploading a File
    Post posted May 2, 2011 by tester26.tester

    Hi All,

    I am facing problem with uploading a file using selenium ( Java). If any one have the solution, please revert back to the following email id with necessary external files to be added to my project in order to run the script.

    My email id  : tester26.tester@gmail.com

    Your reply is appreciated.

    Thanks in advance.

  • Uploading files4
    Post last edited February 9, 2012 by James O'Sullivan

    Hi,

    I'm trying to upload a file as part of a test I'm currently writing, but when I replay the test the filename isn't supplied to the file upload control and therefore the required field validation fails when the form submits.  The selenium code generated is as follows:

    selenium.type(ctl00_cphMain_fvSubjectConsent_fuScannedForm, "test.png");

    Any ideas?

    Thanks,

    James

  • recording in IE2
    Post last edited February 9, 2012 by alanlynott
    Hi, I’ve been using Selenium happily for a while now so I am looking forward to evaluating Twist. My only gripe is that you can only use Selenium with Firefox to record tests. Are there any plans to extend this to cover IE? Some of the systems we work with for our clients run on intranets and are IE specific. Thanks, Al.
  • Window closes after execution5
    Post last edited February 9, 2012 by Preeti

    Hi,

    I am writing a basic script of opening a website in twist using selenium. After execution of my script the execution window closes by itself. I want to keep that window in open state.. can someone help me in this?

    Cheers,

    Preeti

  • Dialogs that still pop-up3
    Post last edited February 9, 2012 by David Mack
    Hello, I know that Twist/selenium has something preventing dialogs from poping-up (alerts, confirms, etc), from what I’ve learned it does this by replacing the function alert with a different version of it that doesn’t display anything. This doesn’t effect the javascript event onbeforeunload (for firefox anyways) because the function does not use confirm () or at least not the “new” version of it. This problem can sometimes be solved by over writing the onbeforeunload function every time you load a page, however this sometimes doesn’t work … thus is not a solid work around. I managed to fix this problem first by modifying firefox chrome file for the default dialog window (making it close it’s self with default button before showing) then i turn it in to a firefox addon and added it to the extensions folder with twist so that it would be included for twist tests. Including an extension like the one I made would solve the problem for others. Thanks,

Filter by Date

< < May 2012 > >
S M T W T F S
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Filter by Type