-->

Basic/Simple Selectors

type selectors




Type /Element Selectors: The most common and easy to understand selectors are type selectors. Type selectors will select any HTML element on a page that matches the selector or node name regardless of their position in the document tree . Used alone, therefor selects all the elements for the given node name.

Syntax



element selectors

Example: View in JSFIDDLE

type selector


There is a huge list of HTML elements that you can select using type selectors which means you can change the look and feel of any element in the DOM.


Class Selectors: These selectors select HTML elements based on the class attribute regardless of their position in the DOM. The class is defined as space-separated list of items and one of those items must match exactly the class name given in the selector.

Syntax


Class Selectors




Example: View in JSFIDDLE

class-selector


Some key points to remember while using Class Selectors:

  1. Classes should not replace HTML elements
  2. Don't overuse classes
Think about the following two important points before using a class selector: 

  1. Is there an existing HTML element that could be used instead?
  2. Is there a class or ID in the DOM that could be used?


ID Selectors: ID selectors are similar to class selectors. These selectors select the HTML element which has an ID attribute.

Syntax

ID selectors




Example: View in JSFIDDLE

The major difference is that ID's can only be applied once per page, while classes can be used as many times as needed.


Universal Selectors: In CSS , * (asterisk) is the universal selector. It is like a type selector which can match any type of HTML element.

It can be used in a universal reset like this:

universal selectors













In CSS 3 , the asterisk can be used in combination with namespaces

  1. ns|E: elements with name E in namespace ns
  2. *|E:   elements with name E in any namespace, including those without any declared namespace
  3. |E:   elements with name E without any declared namespace
  4. E :   if no default namespace has been specified, this is equivalent to *|E. Otherwise it is equivalent to ns|E where ns is the default namespace.

Attribute Selectors: An attribute is a property of an element which can contain values. These selectors picks out nodes based on the value of one of its attributes. 

In the following code segment, text highlighted in red are attributes and the text highlighted in green are attribute values.

attribute selectors





Group id vs Artifact id for a project

Problem:- 
When creating a new project in java IDE, what is the significane of group id and artifact id?

group id intellij

Solution:-
Lets understand what are these values and why we use them.

What?
Group ID :- Its an value which gives unique name to the project (like primary key in SQL tables).

Artifact ID:- Name of the project (jar file will have the same name, when project is build).

Conventions?
Group ID :- Like package in java, it follows the reverse domain naming approach.
Confused ???, lets have a example.

Lets say we have domain as www.ufthelp.com than group id will be com.ufthelp(reverse of domain)
another example, www.google.ca, will be ca.google.

Artifact id:- Its the name of the project (lowercase and longer name seperated by dash).
Example, selenium2library

Note:- 
Version, is the build version of the project, i.e jarname.version example chrome-53.1 (where chrome is the name of thee project, 53.1 is version)

Read more
Learn Java
Learn Selenium

CSS Selectors

What is CSS ? 
CSS (Cascading Style Sheets) is a language that controls the look and feel of html elements in browser. 

Layman example:- Going to beauty salon for hair cut is applying CSS on our face (which is equivalent to HTML). 


css selector comparison with hair cut

What is the meaning of CSS selector? 
Selectors are used to apply CSS styles on html elements. There is an extensive list of CSS selectors available, allowing for close grained precision when targeting elements to style. 

Layman example:- there are numerous types of hair cuts(styles) and various tools to cut hair (CSS selectors). 

How many types of Selectors? 
Selector Types

Selectors can be divided into the following categories: 
Basic/Simple selectors: Match one or more elements based on element type, class, id or attribute/attribute values. 

Pseudo-classes: Match one or more elements that exist in a certain state, such as an element that is being hovered over by the mouse pointer, or a checkbox that is currently disabled or checked, or an element that is the first child of its parent in the DOM tree. 

Pseudo-elements: Match one or more parts of content that are in a certain position in relation to an element, for example the first word of each paragraph, or generated content appearing just before an element. 

Combinations or Group Selectors: These are not exactly selectors themselves, but ways of combining two or more selectors in useful ways for very specific selections. So for example, you could select only paragraphs that are direct descendants of divs, or paragraphs that come directly after headings. 

Multiple selectors: Again, these are not separate selectors; the idea is that you can put multiple selectors on the same CSS rule, separated by commas, to apply a single set of definitions to all the elements selected by those selectors. 

We will be covering all these selectors in detail in the upcoming posts.

CSS positioning??

Verify Regex in Robot Framework?

Problem:- How to verify given regular expression using Robot Framework

Solution:-

A pessimist sees the difficulty in every opportunity; an optimist sees the opportunity in every difficultyyyyy

1.Create a regular expression using online tool
Example:- we want to verify 34.4% we will create a regular expression first 
Regex robot framework



2.Use Should Match Regex keyword

regex robot framework

Example 1 :-
We want to verify whether dynamic pattern like 34.4% exists on UI
Example2:-
Verify that uuid like 9100d6678-1b1c-45b445-bdf9-47bc0b15a603 exists on UI 

Code:-
${cpuUsage} Get Text //test/div 
Should Match Regexp ${cpuUsage} ^[0-9]{1,2}[.][0-9]% CPU Usage validation
${uuidNumber} Get Text //test/div 
Should Match Regexp ${uuidNumber} [0-9a-z-] UUID validation

More Examples

Basic Linux commands for beginners

Scenario:- What are some of basic commands one should know when moving from windows enviornment to linux(say ubuntu)?

Solution:- Its a learning experience when moving from mouse click(windows) to terminal evniornment(ubuntu)

We are trying to cover some the very basic commands, please feel free to add more from experience as comments to this post, as its said
If you want to lift yourself up, lift up someone else ..


1.Sudo(Run as adminstator in windows) - sudo command executes a command with administrative privileges (root-user administrative level), which is necessary
example sudo mkdir test 

mkdir ubuntu

2.mkdir(new folder), creates new working directory in the selected location 

3.pwd, tells the current working directory

4. ls, list all the files in the given folder 

5.ll, another form of listing the items try it out

6.Editing a file :-

  • Open file sudo vi filename
  • press ESC
  • press i (for inserting values into file)
  • move cursor the position where editing need to be done
  • edit
  • type :wq (to write and quit the file after saving)
7.Change to root user, sudo -s
8.Rename a file by using move, sudo mv "oldfilename" "new file name"
9.clear, for clearing the terminal
10. Most important how to launch terminal, press ALT+SHIFT+T
11.How to open new tab in terminal, CTRL+SHIFT+T
12.Get to know the existing used commands in terminal, use history in terminal 

history command in linux

Practical issues and solutions for working with JMeter - Part2

jmeter issues



More Scenarios

Scenario:- 
How to display results from Beanshell sampler to response?

Solution :- 

Simple code example:- 

String display="HelloWorld";

//Taking results and displaying in response
SampleResult.setResponseData( display);

SampleResult.setDataType( org.apache.jmeter.samplers.SampleResult.TEXT );


Scenario:- 
Not able to understand the error message thrown by jmeter in beanshell sampler or beanshell assertions?


Solution :-  

Use try-catch

try{
 int expectedMsgs = ${noOfMessages} * ${messageThreads};
 int actualCount =Integer.parseInt(SampleResult.getResponseDataAsString());
 
 //System.out.print(actualCount);
 if (expectedMsgs!=actualCount) {
    Failure = true;
    FailureMessage ="Expected Messages Sent"+expectedMsgs+"!="+actualCount+"ActualMessages in cassandra";
    print("Expected Messages Sent"+expectedMsgs+"!="+actualCount+"ActualMessages in cassandra");
 }
}
catch(Exception e){
 log.error("Failed check the erro"+e);
 }


Scenario:- 
Connect to remote mySql instance (say ubuntu box) using JMeter?

Solution :- 
Before doing this we need to provide privileges to the remote user to access the database using 
1.SSH into remote machine
ssh username@ip address > enter password

2.Login to mysql using root user
mysql -u root -pPassword
login to mysql using terminal

3.Grant permission as below
GRANT ALL PRIVILEGES ON *.* TO remote@'10.0.110.***' IDENTIFIED BY 'pwd' WITH GRANT OPTION;

4.Make sure to comment the following line in Mysql configuration file,
/etc/mysql/mysql.conf.d/mysqld.cnf 

comment bind-address = 127.0.0.1 using the # symbol


Mysql configuration file

5.Now we can replace the localhost, username and password in our connection settings for mysql.

Note:-
Incase you are getting the below error
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
Solution is run the command uninstall plugin validate_password;

Practical Examples

Practical issues and solutions for working with JMeter - Part1

Most of the time we are struck with very granular issues with JMeter. To overcome these type of hurdles we are sharing the pragmatic solutions to problems.

Refer part2 of learning for more issues

Do share your issues/solutions in the comment section below to help others as we always believe sharing is caring, and Life is short..share while you still have knowledge

Scenario:- 
How to pass random value in Json URI or Json parameters for API call using Jmeter?

Solution :- 
By using "Random Variable"
Where to find in JMeter
Add > Config Element > Random Variable

Name the variable as you want, put the range or create your own formula and start using this variable in Json URI or Json parameters


Random variable in jmeter

Scenario:- 
Not to execute the second sampler if first sampler value fails in Jmeter?

Solution :- 
By using "if controller"
Where to find in JMeter
Add > Logic controller > if controller

In condition add ${JMeterThread.last_sample_ok} 
Note:- Above value is predefined variables in jmeter


if controller jmeter

Scenario:- 
How to execute python script(command script) in jmeter?

Solution :- 
By using "OS sampler"
Where to find in JMeter

Add > Sampler > Os sampler

Example:- Lets say we want to run our MQTT test generator code
We will replicate the command step in OS sampler, 
python3 mqttgen.py 10 10 1  and define the working directory(referring to the script path)


command script from jmeter

More scenarios