Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» FlexMonkium Download Not available under Gorillalogic site
Thu Dec 08, 2016 5:40 pm by bhanu.praveen

» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

How to create/recognize object element not using recording?

View previous topic View next topic Go down

How to create/recognize object element not using recording?

Post by maggiexg on Wed Sep 23, 2009 4:17 am

Hi,

I have the following questions:

1. How to create an object element not using recording method?
for example, by scripting
clickandwait
Go (image link)

Will Selenium find the Go link on the page? Can we use the labels on the screen to run as many actions as we like this way?

2. How Selenium recognize a UI element?

Thanks,

MX

maggiexg

Posts : 3
Join date : 2009-09-23

Back to top Go down

Re: How to create/recognize object element not using recording?

Post by Adviser on Wed Sep 23, 2009 10:58 am

hi,

If you want to create script manually not using record and play feature of selenium, it is simple.

For this you have to start you application and IDE. Suppose you have login page and you want to create object for all object present on that screen. The following are steps:

1. go to first element username field, right click with mouse. It will show some command of selenium in mouse popup. select verifyElementPresent.
2. Moe one step is recorded in selenium ide. go and have a look.
3. Now modify that command, do type instead of verifyElement.
4. leave the Target field, it is your object locator.
5. Type username in value option of IDE.

By this way you can get object of any element and modify according to your need. Selenium will not find "GO" you have to provide actual dom locator or xpath.

Selenium will recognize the element in following ways:

Element Locators tell Selenium which HTML element a command refers to.
The format of a locator is:

locatorType=argument
We support the following strategies for locating elements:



identifier=id
Select the element with the specified @id attribute. If no match is
found, select the first element whose @name attribute is id.
(This is normally the default; see below.)
id=id
Select the element with the specified @id attribute.
name=name
Select the first element with the specified @name attribute.

  • username
  • name=username

The name may optionally be followed by one or more element-filters, separated from the name by whitespace. If the filterType is not specified, value is assumed.

  • name=flavour value=chocolate


dom=javascriptExpression


Find an element using Javascript traversal of the HTML Document Object
Model. DOM locators must begin with "document.".

  • dom=document.forms['myForm'].myDropdown
  • dom=document.images[56]


xpath=xpathExpression
Locate an element using an XPath expression.

  • xpath=//img[@alt='The image alt text']
  • xpath=//table[@id='table1']//tr[4]/td[2]


link=textPattern
Select the link (anchor) element which contains text matching the
specified pattern.

  • link=The link text


css=cssSelectorSyntax
Select the element using css selectors. Please refer to CSS2 selectors, CSS3 selectors
for more information. You can also check the TestCssLocators test in
the selenium test suite for an example of usage, which is included in
the downloaded selenium core package.

  • css=a[href="#id3"]
  • css=span#firstChild + span

Currently the css selector locator supports all css1, css2 and css3
selectors except namespace in css3, some pseudo classes(:nth-of-type,
:nth-last-of-type, :first-of-type, :last-of-type, :only-of-type,
:visited, :hover, :active, :focus, :indeterminate) and pseudo
elements(::first-line, ::first-letter, ::selection, ::before, ::after).

Without an explicit locator prefix, Selenium uses the following default
strategies:



  • dom, for locators starting with "document."

  • xpath, for locators starting with "//"

  • identifier, otherwise


Hope this will help you. Best of luck.

Bye

Adviser
------------------------
------------------------

Posts : 379
Join date : 2009-07-30
Location : India

http://seleniumforum.forumotion.net

Back to top Go down

Re: How to create/recognize object element not using recording?

Post by maggiexg on Wed Sep 23, 2009 11:38 am

Hi Adviser,

Thanks for the detailed explainations and I found the context menu by following your steps. It is so helpful!

MX

maggiexg

Posts : 3
Join date : 2009-09-23

Back to top Go down

Re: How to create/recognize object element not using recording?

Post by kmahata@gmail.com on Sat Nov 07, 2009 2:48 pm

Hi Maggie

U may use Firebug addon in FF. Through this u can know the locators. Capture them and type the command u want to perform on them

kmahata@gmail.com
Active particpant
Active particpant

Posts : 10
Join date : 2009-11-06

Back to top Go down

Re: How to create/recognize object element not using recording?

Post by Sponsored content Today at 3:23 am


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum