Friday, February 16, 2024

Vlookup


VLookup is the method, the arguments are..

  1. 1st argument is what to search(Example -the letter A[A8]).
  2. 2nd argument is where to search(A1:C4)
  3. 3rd argument is what is the equivalent value required, specified with column number 1,2,3
  4. 4th argument is like extract mach or not specified with boolean value TRUE/FALSE.





Thursday, February 8, 2024

DTC logic

SAE - Society of Automotive Engineers
0x96A123 ---Consider as sample dtc
Examples:
DTC_0x96A123
DTC_0x96A223
DTC_0x96A323

split the byte as,
DTC_0x96A1 -----23

Search in the DTC database as,
96A1

After search you can find out like ,
P16A1 or C16A1 or B16A1 or U16A1

P-00-powertrain
C-01-chassis
B-10-body
U-11-network

here,

96A1
9=1001
where
10 -is body and 01 is OEM Specific.

B16A1 -SAE Format
0x96A1 -Hex Format

what is nibble ?
4-bits
lower nibble /upper nibble:

10 01                01 10
if  DTC Status is not considered then length is  2 byte only ( mostly not considered)
B1 6  A1 23

B-10
1-01
6- 0110

B16 - 1st byte
A1 -10100001-2nd byte
where A1 is Failure type  or Fault type byte.


last byte 23(0010 0011) is status mask,

note-reading data as
byte-left to right
bit-right to left

bit 0 -1-Test Failed-fault is active.
bit 1 -1-Test Failed this Operation cycle-fault has occurred anytime during the current operation cycle.
bit 2 -0-Pending DTC-the no. of re-occurrences and number of drive cycles
bit 3 -0-Confirmed DTC -it has been continuously active for some behavior(routine)
bit 4 -0-Test Not Completed Since last clear-if behavior(routine) is not completed.
bit 5 -1 -Test Failed Since Last Clear - After clear the DTC, again it will reappear in any operation cycle.
bit 6 -0-Test Not Completed This Operation Cycle -if monitoring routine has not run.
bit 7 -0-Warning Indicator Request -if MIL light is turn on.








 

Thursday, May 8, 2014

XPath


About XPath

  • XPath is language-(XML Path Language)
  • It Specifies the address of the XML.

Used to:

It points the elements and attributes of XML

Types:
Relative xpath-starts with current node
                example- //*[@id="yschsp"]
Absolute xpath-starts with root node
                example- /html/body/div[3]/div/div/div/form/div/input


Way to find X-path

Using Fire-bug add-on in Firefox browser as
By inspect the need element and right click it means,copy Xpath option is available-to copy it and 
pasted in Fire-Finder (add-on for Firefox) and click filter (or) pasted in Fire-path (add-on for Firefox) and click Eval
Which can height-light the element.


XPath expressions(syntax)

1.Finding by id-//*[@id="yschsp"]------>this example x-path in http://in.search.yahoo.com/
      where * is retrieve all the elements.

2.Finding by name-//*[@name="p"]------>this example x-path in http://in.search.yahoo.com/

//*[not(@name="p")]-by giving the not of name (attribute) p.which select other than p.

3.Finding by class-//*[(@class="sbq")]------>this example x-path in http://in.search.yahoo.com/

4.Finding by type-//*[(@type="text")]------>this example x-path in http://in.search.yahoo.com/

5.Finding by contains of text,id,name,etc.,

    i)//form/div/div/p[contains(text(),'By')]----->this example x-path in https://www.facebook.com/
    ii)//form/div/button[contains(@name,'btnK')]-->this example x-path in google.co.in
    iii)//form/div/button[contains(@id,'gbqfbb')]-->this example x-path in google.co.in

6.Finding by starts-with of text,id,name,etc.,

   i)//div[starts-with(@id,'gbqfb')]-->this example x-path in google.co.in
   ii)//div/*[starts-with(text(),'Google')]-->this example x-path in google.co.in
   iii)//div[starts-with(@class,'gbqfq')]-->this example x-path in google.co.in
   

7.Finding the ancestor as (parent, grandparent, etc.)
  
        //div/div/ancestor::table-->this example x-path in google.co.in

8.Finding the descendant as (children, grandchildren, etc.)

    //div/div/descendant::a-->this example x-path in google.co.in
    //div/descendant::a[@data-pid=119]-->this example x-path in google.co.in

9.Finding by id as last node
      
       //div/div/a[starts-with(@href,'https://a') and last()-9]-->this example x-path in google.co.in

10.Finding the parent node
        
    //div/a/parent::*-->this example x-path in google.co.in

11.Finding the child node

    //div/table/child::*-->this example x-path in google.co.in

12.Finding by operators

    //div/a[@data-pid=119-96]-->this example x-path in google.co.in
    where 119-96=23,so points to the attribute of data-pid=23
  
13.Finding by position

    //div/div/div[contains(@class,'gb_d gb_e') and position()=3]-->this example x-path in google.co.in


Thursday, April 10, 2014

Talking screenshot with selenium webdriver using c# with app configuration


Sample code for talking screenshot with selenium webdriver using c# with app configuration

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support;
using OpenQA.Selenium.Support.UI;
using System;
using System.IO;

namespace ConsoleApplication5
{
    class Program
    {
        public static void Main(string[] args)
        {
            string website =                                                                     System.Configuration.ConfigurationSettings.AppSettings["url"];

            string pages =                                                                    System.Configuration.ConfigurationSettings.AppSettings["page_name"];

              string[] saparated_pages = pages.Split(',');

            //Specify browser driver path
            IWebDriver driver = new ChromeDriver(@"D:\");

            //Site Launch
            driver.Navigate().GoToUrl(website);

            //Getting screenshot
            Screenshot ss1=((ITakesScreenshot)driver).GetScreenshot();

            //Specify variable value as current time to set for filename
            var filename=DateTime.Now.ToString("MM-dd-yyyy,h-s-m tt");

            //Save the screenshot with specified location&image format
            ss1.SaveAsFile(@"D:\selenium_images\" filename+".png",
            System.Drawing.Imaging.ImageFormat.Png);

            for (int j = 0; j < 3; j++)
            {
                 driver.Navigate().GoToUrl(website+"/"+ saparated_pages[j]);
              Screenshot ss=((ITakesScreenshot)driver).GetScreenshot();
              var file_name=DateTime.Now.ToString("MM-dd-yyyy,h-s-m tt");
              ss.SaveAsFile(@"D:\selenium_images\" + file_name + ".png",                       System.Drawing.Imaging.ImageFormat.Png);
            }

            //close the browser
            driver.Close();
           
        }      
    }
}
  

//app config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="domain_name" value="http://www.google.com"/>
    <add key="page_name" value="imghp,photos,document"/>
    <add key="url" value="http://www.google.com"/>
  </appSettings>
</configuration>

To create the App Config as,

Step 1:Right the project name in solution explorer
Step 2:Add->New item
Step 3:choose Application configuration file in visual studio installed templates
Step 4:name the templates
Step 5:its open with

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
</configuration>

Step 6:include the app settings where its keys and value as above program
Step 7:to call the app config as with "System.Configuration.ConfigurationSettings.AppSettings["url"]; "
where URL is the key.which retrieve the values from the particular key


Monday, April 7, 2014

Capturing the screenshot and Assignid command in Selenium IDE


Capturing the screenshot in Selenium IDE

It enables to take the screenshot of the current webpage in the Firefox browser.

Syntax:
Command: captureEntirePageScreenshot
Target: d://google.png

where d:// is the location and google.png is filename of image,the image type is in png format.





Assignid

which helps to overwrite the Id,name(as like that)...
This command is helpful when the Id,name are no meaningful, not understand and not able to memorize means it enable to give meaningful, understand and memorable one.

Syntax:
Command: assignId
Target: name=btnG // here either be give name or id(name=btnG,id=gbqfq)
Value: Search_button


Thursday, April 3, 2014

Selenium IDE using javascript to get date, hit the URL, keypress and sendKeys commands


Here this post helps to explain in detail of javascript usage and keypress &sendKeys command.

Topics
1 - how to get the current date and time using Selenium IDE.
2 - how to hit URL multiple times in browser window using Selenium IDE.
3 - By using the keypress command with the ASCII value of key in Selenium IDE.
4 - to know the sendKeys command and difference between type and sendKeys.

1)to get the current date and time using Selenium IDE as,

 Command :Store
  Target :javascript{ new Date().getDate()+":"
            +(new Date().getMonth()+1)+":"
            +new Date().getFullYear()+":"
            +new Date().getHours()+":"
            +new Date().getMinutes()+":"
            +new Date().getSeconds()
            }
   Value:time

 
  to view the time in selenium ide as,

  Command :echo
   Target :${time}

2)to hit URL multiple times in browser window using Selenium IDE as,


    Command :Store 
    Target :javascript{
            var i;
            for(i=0;i<5;i++)
            {
            var a=window.open("http://www.yahoo.com");
           }
         
3)by using the keypress command with the ASCII value of key in Selenium IDE as,
 
    Command:keyPress
    Target:id=gbqfba
    Value:\\13  

   here,13 ASCII VALUE for enter key, it performs the function as like "by pressing the enter key".This command helps, when after giving the  username and password,by pressing the enter key it automatically goes to the respective page.
 
4)the sendKeys command and difference between type and sendKeys

    The sendKeys command also like type command,
    the difference is that sendkeys command is concatenate text(or)letters with existing text.
    but type command is not concatenate text(or)letters with existing text,
    it erase existing and type new one(what we given into it)
     
       Command :sendKeys
       Target  :id=gbqfq
       Value   :google

Wednesday, March 19, 2014

Configure with eclipse-Selenium Webdriver and RC

New work-space:


New workbench:


Creating new project:


By clicking java project and give the project name>click next:


Click finish




After clicking finish, it looks as like this…


Next: to create folder within project for importing jar files of Selenium, TestNG


Give the Folder name and click finish


Given folder is present under project:


Download selenium 



Import jars files as copy and paste into the folder
Or
Go to choose folder>right click>build path>configure build path


Click libraries



Click>libraries tab>add external jars and browse the selenium download and click open


Now click>OK
Here: selenium-server-standalone-version is added


Configure build path


Click>OK




Creating package:
File>new>package


Creating class:



Click finish





Adding sample of Selenium RC commands


Here click import Firefox driver


Run as java application:


Before save it else it ask as like this


Thursday, March 13, 2014

Selenium Webdriver- Sample Code

//using the namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            //launch the browser as chrome and add the 
            //location of browser driver
            IWebDriver driver = new ChromeDriver(@"D:\");

            //driver takes to the particular page as 
            driver.Navigate().GoToUrl("http://www.google.com");

            //finding the input element as id
            IWebElement search_box=driver.FindElement(By.Id("gbqfq"));

            //pass the value to element(search_box)
            search_box.SendKeys("selenium webdriver tips and tricks");

            //finding the input element as name
            IWebElement Search_button =driver.FindElement(By.Name("btnG"));

            //click the button(search_button)
            Search_button.Click();

            //getting the title of the browser window
            String title = driver.Title;
           
            //display the title
            Console.Write(title);

            //To close the driver 
            driver.Quit();
        }
    }
}

Selenium Webdriver with visual studio c#


Configuration to start with Selenium Webdriver with c# in visual studio

Step 1:Open the Microsoft Visual Studio

Step 2:File->New->Project

Step 3:Choose Project types as Visual c# and choose Console Application in Templates


Step 4:Name the project(by default it as ConsoleApplication)

Step 5:Click ok

(before proceed the 6th step to download the Selenium Client & WebDriver Language Bindings
in the language of c# in http://docs.seleniumhq.org/download/)

Step 6:Add the reference dll[ by right clicking the (References and Add Reference)in Solution Explorer Window]

Step 7:In Add Reference ->Browse Tab->choose the file of downloaded location
(if the file is in zip format means extract it)
and upload the dll files of either net35 or net40

Step 8:And the download the browser driver that what the browser you want

Step 9:Start to playing with Selenium Webdriver with c# in visual studio


Wednesday, February 26, 2014

Selenium RC - Sample Code

Work with Selenium RC in eclipse:

//package package_name
package webdriver;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.firefox.FirefoxDriver;

import com.thoughtworks.selenium.Selenium;

//class class_name
public class webdriver_exercise {
public static void main(String[] args) throws Throwable {
// TODO Auto-generated method stub
// set the execution file and its path
System.setProperty("webdriver.firefox.bin",
"C:\\Program Files (x86)\\browser\\Mozilla Firefox 19.0\\firefox.exe");
// connecting to Firefox driver
WebDriver driver = new FirefoxDriver();
// for both WebDriver and RC
Selenium selenium = new WebDriverBackedSelenium(driver,
"http://www.bing.com/");
// open the browser
selenium.open("http://bing.com/");
selenium.waitForPageToLoad("100");
// type the text in search box
selenium.type("name=q", "selenium with rc example");
// click the search button
selenium.click("id=sb_form_go");
// close the browser
selenium.close();
}
}