Sunday 1 May 2016

What is Xpath and how to write Xpath ?


In my previous post I have explained how to get HTML code for particular web element and view the tags, attributes and values.In this tutorial we will learn that how to write xpath to uniquely identify web elements so that we can perform actions like click , type and double click on them.

Xpath is w3c recommendation which is used to traverse XML document by using path expression. We are going go see simple examples of writing Xpath which will be useful for us in writing selenium automation test cases.

If you observe the HTML code then you will notice that for each tag there are attributes and values for it. We need to use these attributes and values to write our xpath. HTML tags are like <div>, <input >, <a>, <span> etc. The attributes are like id, class,href,text etc. And each attribute will have value.So using this we can create our own combination of Xpaths.

Video Tutorial -

 

I will tell you most commonly used syntax in writing xpath. 
// - to refer Node/Tag
@ - to refer attribute
' ' - to specify value

If you know these 3 then half of your work is done.

Let us see some examples of Xpath 

1.  //input[@class='cname']

2. //span[@text='textvalue']

3. //div[@class='classvalue'][contains(@onclick,'text value')]

4. //div[contains(@class ,'cname') and text()='Hello Text']

These are few sample examples which are pretty much self explanatory. If you know the tag name, attribute and value then you can use them to write your xpath as shown the above example. If you have any doubts or suggestions feel free to drop a comment.


22 comments:

  1. Crypto-currency as a modern form of the digital asset has received a worldwide acclaim for easy and faster financial transactions and its awareness among people have allowed them to take more interest in the field thus opening up new and advanced ways of making payments. Crypto.com Referral Code with the growing demand of this global phenomenon more,new traders and business owners are now willing to invest in this currency platform despite its fluctuating prices however it is quite difficult to choose the best one when the market is full. In the list of crypto-currencies bit-coins is one of the oldest and more popular Crypto.com Referral Code for the last few years. It is basically used for trading goods and services and has become the part of the so-called computerized block-chain system allowing anyone to use it thus increasing the craze among the public, Crypto.com Referral Code.

    Common people who are willing to purchase BTC can use an online wallet system for buying them safely in exchange of cash or credit cards and in a comfortable way from the thousands of BTC foundations around the world and keep them as assets for the future. Due to its popularity, many corporate investors are now accepting them as cross-border payments and the rise is unstoppable. With the advent of the internet and mobile devices,information gathering has become quite easy as a result the BTC financial transactions are accessible and its price is set in accordance with people’s choice and preferences thus leading to a profitable investment with Crypto.com Referral Code Code. Recent surveys have also proved that instability is good for BTC exchange as if there is instability and political unrest in the country due to which banks suffer then investing in BTC can surely be a better option. Again bit-coin transaction fees are pretty cheaper and a more convenient technology for making contracts thus attracting the crowd. The BTC can also be converted into different fiat currencies and is used for trading of securities, for land titles, document stamping, public rewards and vice versa.

    Another advanced block-chain project is Ethereumor the ETH which has served much more than just a digital form of crypto-currency Crypto.com Referral Code and its popularity in the last few decades have allowed billions of people to hold wallets for them. With the ease of the online world,the ETH have allowed the retailers and business organizations to accept them for trading purposes, therefore, can serve as the future of the financial system.

    ReplyDelete
  2. Our full Lace Front Wigs are all hand made with a lace cap. They are manufactured with thin lace sewn on top of the cap. Individual hairs are then sewn onto the thin lace. Each lace wig has lace all around the unit which will need to be cut prior to securing the wig to your head. You will need to cut along the hairline around your entire head. By doing so, you will be able to wear your hair anyway you like. You can even style ponytails, up-dos, etc. Once the Lace Wigs is successfully applied, it will appear that all the hair is growing directly from your head!

    Lace front wigs are hand-made with lace front cap & machine weft at back. Lace front wigs are manufactured with a thin lace that extends from ear to ear across the hairline. When you receive the wig, the lace will be quite long in the front. Cut and style according to your preference, as you will need to apply adhesive along the front of the wig. Once the wig is applied, you will still have Lace Wigs with a very natural appearance.
    TeamWigz Provide the Best Lace Front Wigs and Lace Wigs in Johannesburg and South Africa.

    ReplyDelete
  3. 우리카지노 에 오신 것을 환영합니다. 국내 최고의 카지노사이트 에 가입하여 바카라사이트 에서 다양한 게임을 즐기시면서 대박의 기회를 놓치지마세요! 우리 카지노는 한국의 바카라 산업을 지배하는 카지노 사이트입니다. 우리 카지노는 한국 바카라 시장 점유율의 50 % 이상을 차지하는 10 년 이상 온라인 바카라 시장을 지배 해 왔기 때문에 우리 카지노를 모르는 사람은 거의 없습니다.

    ARTICLE: 우리카지노는 대한민국의 바카라 업계를 장악하고 있는 카지노사이트 입니다. 우리카지노가 대한 민국에서 장악한 바카라 시장점유율이 50%가 넘고 10년 넘게 온라인 바카라 시장을 장악해왔기 때문에 대한민국에서는 우리카지노를 모르는 사람은 드뭅니다. 이런 바카라 업계의 독보적인 입지 때문에 늘 유명하거나 최고만을 찾는 사람들이 카지노사이트를 찾을때는 늘 우리카지노를 찾습니다.바카라를 처음 시작하시는 초보자분들에게도 우리카지노에서 카지노사이트를 시작하시기 좋은 환경입니다. 우리카지노사이트에서는 신규가입시 3만쿠폰을 지급 해주기 때문입니다. 사람들이 늘 1등만을 찾는 이유는 분명 있습니다. 다른 카지노사이트와는 달리 우리카지노를 이용하실시 에이전트를 끼고 게임을 하신다면 본사 이외에 활동쿠폰 및 오링쿠폰을 별도로 제공해주고 있기 때문입니다. 이러한 이유들 때문에 카지노사이트 업계에서 바카라를 즐기신다면 다들 우리카지노를 선호 하십니다. 카지노사이트에서 바카라를 이기기 물론 어렵습니다. 하지만 우리카지노의 에이전트를 끼고 바카라를 즐기신다면 승산이 있다고 봅니다. 우리카지노 에이전트의 연락처는 홈페이지로 연락하시면 언제든지 부담없이 소통가능 합니다. 카지노사이트를 선정할때는 바카라를 다른곳보다 유리하게 즐길 수 있는 카지노를 선택해야한다고 생각합니다. 그것이 바로 우리카지노 입니다. 이상으로 우리카지노와 바카라 카지노사이트 사이의 상관관계를 알아보았습니다바카라사이트.

    ReplyDelete
  4. Purchase EMAIL LIST FROM RIGHT PROVIDER

    Email is an individual method of connecting to your possibilities. What's more, purchase email lists since it is a private message, trust and association are assembled as of now. The change rate is likewise higher contrasted with established press because of low operational and overhead expenses. What's more, email is simpler to screen and assess than printed materials. Through email showcasing, you can kick off your b2b lead age paying little mind to what kind of industry you are in. The initial step to purchase email list for promoting is picking the correct email list supplier. You have to purchase email rundown to get tightly to the important data of your future customers for your image. Along these lines, it will be simpler for you to look for organizations, discover contact people and leaders and approach your item and administrations.

    ReplyDelete
  5. Internet Download Manager 6.38 Build 10 IDM Crack Patch with Serial Crucial down load is a sort of shareware downloadmanager possessed by an American company called Tonec Inc.. IDM Patch Free Download captures any type of download in a extraordinary time limit and completes the download at a very brief time and at a faster speed as compared to any download manager right now. IDM company is based in nyc. IDM Download Free Full Version with Serial Key This computer program is readily designed for Windows OS just for now.
    Presently IDM Serial Crucial Free has turned into a renowned application with over 20 million clients around the globe. Internet download manager Hack may take downloads from many browsers like Internet Explorer, Microsoft Edge, Google Chrome, Opera, Firefox for practically just about any kind of record of user's choice. It has gained control over down load; nevertheless, it shows its dialog box to an individual.

    ReplyDelete
  6. Dubai business directory has business listings, phone numbers, maps, email addresses and websites for local businesses in Dubai to help you get the job do.

    ReplyDelete
  7. Friendly Finance is South Africa's number 1 choice for finance - providing customers with all the information they need to make better financial decisions. We provide hundreds of comparisons of common consumer finance products, pay day loan such as personal loans, car loans, short-term loans and credit cards. Think of us as a helping hand in selecting consumer finance products.


    ReplyDelete
  8. ChemLab Store Store provide you with top quaility research chemicals like: A-pvp, Methylone Crystals, buy jwh 210 online usa Methylone Powder, Pentedrone Crystals, Pentedrone Powder, MDPV Powder, Buphedrone Powder, 4-FMC Powder, 4-MemABP Powder, NEB Powder, AMT Powder, 6-APB Pellets, Butylone Powder, MDAI Powder, 4-FA Powder, 4-FA Crystals, MPA Powder, Methoxetamine, JWH-122 Powder, JWH-122 Herbal Buds, Ketamine, AM-2201, Herbal Buds, We have a wide range of products including JWH-018, JWH-073, JWH-200, JWH-250, 4-MEC, 5-IAI, Phenazepam, 2c-i, Actavis Promethazine, Naphyrone, U-47700. Methedrone, crystal meth and other chemicals in all different amounts ranging from 5gm to 1kg retail and also large amounts at wholesale prices, When you buy Research Chemicals or bath salts from us you are guaranteed of the highest quality available on the market, high purity products, secure payment, fast and discreet international delivery.

    Disclaimer: None of the Products on ChemLab Research Chem Store are intended for human consumption and Neither ChemLab Research Chem Store,

    nor any of the staff INCLUDING the owner of ChemLab Online Chem Store resume ANY responsibility for ANY injuries to ANY individual who does not correspond with this warning and will not be held accountable for any loss or damages due to an individual burning, inhaling, or consuming into the body of any human being, animal or living specimen. This statement applies to all of the products sold on this site.

    By purchasing ANY PRODUCT ON THIS SITE, You Agree to be held 100% liable for any personal injury or damages due to you (Customer) using any of the products in any way other than that manufacturer’s instructions of use printed on the package!

    ReplyDelete
  9. Testimonial Review of Taskade, Taskade Testimonials the all-in-one collaboration platform for remote teams. Unleash your team productivity with task lists, mindmaps, and video chat.

    ReplyDelete
  10. Recently, the keto diet has become extremely popular for its health benefits such as weight loss and preventing disease. A custom Keto plan for life! Visit: custom diet

    ReplyDelete
  11. - Como organizar sua Semana com o Taskade - Segunda Feira, primeiro dia.
    - Como organizar sua semana com o Taskade - Terça - Vlog de Produtividade
    - Como organizar sua semana com o Taskade - Quarta
    Como organizar sua semana com o Taskade - Quinta - Vlog Produtividade.
    - Taskade - Sexta, Sábado e Domingo. Como foi e uma grande novidade

    ReplyDelete
  12. PMP certification is the globally recognized certification for project management. It is the validity given by the PMI Institute to candidates who clear certain education and professional criteria - Pass PMP.

    There are many ways to Pass PMP certification.


    Go for the heavy books, memorize them, sit for PMP trainings on your weekend, sit in the long, sleepy PMP video on demand trainings and still have the unsurety of passing the exam.
    Get PMP dumps, PMP practice exams, PMP review material and try to memorize hundreds of questions and still fear of forgetting some and getting new questions as PMP changes very frequently.
    Contact CBTproxy and through PMP proxy exam, PMP Brain Dump get your PMP certification without any hassle.
    There are several sites selling PMP dumps and PMP exam questions which are 90% not reliable. Since there are always new questions in PMP exam, there is no reliability on the PMP dumps. Contact CBTproxy and through our PMP proxy exam, Pass PMP Certification without any hassle. We ensure first time passing guarantee and liberate the candidate from taking the real exam multiple times - PMP dumps.

    ReplyDelete
  13. Descubre los mejores diseños de alfombras vinilicas y azulejos adhesivos para decoración e interiorismo. Alfombras infantiles Envío gratis

    ReplyDelete
  14. Buy Modafinil Online – Buying pills like Modafinil is not easy. Are you trying to purchase modafinil online? If your answer is Yes, then you are in the right place. In this buyer’s guide, we are going to cover everything you need to know about the most popular nootropic in the world.

    ReplyDelete
  15. Why Your Online Business Needs A WordPress Website

    The WordPress site framework is currently the most generally utilized site building stage on the web, with more than 22% of all dynamic areas utilizing it. This site program has the usefulness to assist your online business with procuring income also giving as a total substance the board framework.

    There are in excess of 75 million WordPress sites on the web and it is supposedly utilized by numerous lofty associations. On the off chance that it is adequate for them, it will doubtlessly be sufficient for your online business.

    A Flexible Website Builder. wordpress pre built websites

    WordPress is an entirely adaptable program for an online business. You have the choice to post customary news things onto your site and make explicit item deals pages. You can decide to permit remarks on your pages which makes client created content as peruser's remarks. Updates can be planned for advance so that pages can go live at a pre-decided time and you can make certain pages private so just your clients with the particular URL can get to them.

    Creator Management.

    The program permits you to have numerous clients with various degrees of power. You can let others to make and add substance to your site without giving them full access rights to the whole site situation. You likewise can check and support any updates before they go live.

    WordPress Website Templates.

    At the point when a guest lands on your site, you just have seconds to dazzle them and convince them to remain. With the site layouts (called subjects) you can transfer an immense wide range of topics at the snap a catch. A few subjects are free and some have a little expense and there will be a topic that gives the look and highlights that you need for your online business. You can likewise effectively review and trade between subjects to see which one you like best.

    A WordPress Website Design To Suit You.

    The fundamental site download is a minimal programming system and you do have to add the additional items, or modules, to expand your site's abilities. Numerous modules are free and permit you to do various things including the formation of mailing records, contact structures, connect following, site design improvement frameworks, site investigation and the sky is the limit from there.

    Since there are so numerous WordPress sites on the web there are individuals everywhere on the world who create additional items, modules, topics for you to download to your site. What was once utilized for publishing content to a blog has now developed into an exceptionally incredible program to assist you with making a site that will attract the traffic and bring in cash for you.

    ReplyDelete
  16. Universal Gun sales is a trusted Firearm company base in Los Angeles California USA. It is one of the top Firearms Company in this part of the country. Buy Ammunition online They do offer the best firearms deal in the USA and to over 25 countries in the world. You can always visit their shop in Los Angeles using the address on their website. Place your order and get served by the best Firearm Company in the planet. Have fun.

    ReplyDelete
  17. If you're looking for free movies online feel free to visit the site. bazflix You can watch unlimited movies and tv shows without any registration. Bazflix has thousands of movies and tv shows online.

    ReplyDelete
  18. Massage Mundaring is run by a talented female massage therapist and is based from her home studio in Mundaring. Trained in an introductory Traditional Thai Style Yoga massage course, in Northern Thailand mid 2015, Her eyes opened to the different cultural style of massage, which is offered fully clothed with pressing, Click here stretching, extending and rotating techniques focusing on meridian and acupressure points. Her chosen style of massage is Deep Tissue and Trigger Point which she believes to be powerful at unlocking and manipulating the muscle fibers, allowing new oxygen and blood to restore the tissue. Her technique is described by her clients as fluid, deep, rhythmic, releasing and restorative.

    ReplyDelete
  19. Understanding about Synthetic Thatch is important to get a Solid Roof for your Homes, Beach Resorts, Water Parks and Restaurants. Synthetic Thatch Roofs are the ultimate roofing choice for making Roofs look cozy, ethnic, or even tropical. Because Synthetic thatch makes such a Perfect Roofing Material, Our Synthetic Thatch Roofing Material with Synthetic Bamboo Panels Products can Never Replaced by Any Other Conventional Roofing Materials.Aluminum Bamboo , Bamboo Fence and Artificial Bamboo evokes with the feeling of beach resorts, relaxing vacations and tropical atmospheres. However, the natural thatch and bamboo has a variety of downsides, such as Fire Hazards, wind issues, insects and rotting. Even though the initial cost is only a little bit lower than synthetic products when you purchase on season Bamboo Poles for Sale but the maintenance fee in the future is a nightmare.
    Tiki torches & Synthetic Bamboo Poles with Artificial Bamboo Products for Synthetic Bamboo Matting offer an easy way to build Homes, Beach resorts, Water Parks and Restaurants anywhere without worrying about maintenance fee.Our Synthetic Thatch Roofing Material & Artificial Bamboo Products Made from Very High in Quality, long-lasting, eco-friendly, fire-retardant and UV-Resistant Synthetic thatch roofing material with are Maintenance-Free. Our Synthetic Thatch Roofing Products are created using molds taken from real synthetic thatch and Artificial bamboo. This allows our products to look exactly like the natural products while being made from a durable, long-lasting, and maintenance-free material.You’ll be astonished at how well our Bamboo Panels withstand ocean breeze, heavy rain, snow storm, intense sunlight and general wear & tear for more than 20 years while still looking amazing.

    ReplyDelete