TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Selenium CSS Selector - Attribute

Selenium CSS Selector - Attribute with Introduction, features, selenium basic terminology, what is selenium, selenium limitations, selenium vs qtp, tool suite, selenium ide, ide-installation, ide-features, ide-first test case, ide-commands, ide-creating test cases manually, ide-login test etc.

<< Back to SELENIUM

CSS Selector - Attribute

  • Syntax: css=<HTML tag><[attribute=Value of attribute]>
  • We can use value, type and name as an Attribute to create a CSS Selector.
  • Value of attribute denotes the value which is being accessed at the time of using a particular attribute.

Let us consider an example on how to use an Attribute to create a CSS Selector which uniquely identifies a web element.

We will try to locate a web element by defining the CSS Selector for that particular web element.

  • Launch Firefox browser.
  • Click on the Selenium icon present on the top right corner on your browser.
  • It will launch the default interface of Selenium IDE.
  • Click on the command text box present on the Test Script Editor Box.

CSS Selector - Attribute
  • Modify the properties of first command as:

CSS Selector - Attribute

Now, using second command we will try to locate the "Username" text box.

First we will inspect the "Username" text box to determine which attribute will be best suited to locate the desired web element.

    • Right click on the Username text box and select inspect elements.

CSS Selector - Attribute
    • It will launch a window containing all the specific codes involved in the development of "Username" text box.

CSS Selector - Attribute
    • Pick the input tag along with the value of name attribute.

CSS Selector - Attribute

We will define the CSS Selector as: css=input[name='email_id']

  • Modify the properties of second command as:
    • Command: click at
    • Target: css=input[name='email_id']
    • After execution, this command will click on the "Username" text box.

We will add one more command using the same CSS Selector. This command will type the username text into the "Username" text box.

  • Modify the properties of third command as:
    • Command: type
    • Target: css=input[name='email_id']
    • Value: username
    • After execution, this command will type the value in the "Username" text box.

CSS Selector - Attribute

Let us execute our test script to see whether our inserted commands are working or not.

  • Click on the "Run Current Test" button present on the tool bar menu of the IDE. It will execute all of your inserted commands on the browser and gives you an overall summary of the executed test script.

The following screenshot shows that we have successfully executed our test script.


CSS Selector - Attribute

(1) - Value of name attribute is used for both of our CSS Selector's to locate the "Username" text box element.

(2) - Log pane displays the overall summary of the executed test script.

(3) - Value generated as a result of execution of our third command.





Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf