|
Knowledge Management for Learning Communities |
| Login | |
SeleniumNOTE :This wiki page is now available at http://www.openacs.org/xowiki/pages/en/Testing+with+Selenium Selenium TestingSelenium is primarily for user interface and acceptance testing. Command Reference :http://selenium.thoughtworks.com/seleniumReference.html Some Limitations :
Tips :Use xpath to find specific html elements I have scenario where I want to click ona image field with no id or name attribute so there's no easy way to tell selenium to click it. We can either ask the designer to put an id or name attribute or use xpath. Let's say the image button in question looks like this <input type="image" src="images/long-login-btn.gif" width=166 height=15 /> the xpath syntax will be //input[@src='/images/long-login-btn.gif'] and you can use this in conjunction with clickAndWait Use javascript to create dummy values You can use javascript to generate values like so javascript{'test' + (new Date()).getTime()}and use store to store them to a value for use later in the selenium script. Select Radio Buttons based on label instead of value This is an issue that was raised while tackling test scripts with assessments. Thanks to Guillaume Boudreau from the selenium mailing list. " click //input[@type='radio' and following-sibling::text()[1]=' MD'] " Which mean: find the input of type='radio' for which the next 'sibling' text is ' MD'. To make sure it works, replace ' MD' with ' EdD' and you should see the correct radio being selected. Also, (will work in this particular case, but the above syntax is better) " click //input[@type='radio' and position()=1] " or " click //input[@type='radio'][1] " Another way is to use the contains function click //input[@type='radio' and contains(following-sibling::text(),'MD')] | |