Это видео недоступно.
Сожалеем об этом.

TestNG Data Provider - How to get test data from Excel in Selenium using TestNG Data provider

Поделиться
HTML-код
  • Опубликовано: 1 авг 2024
  • TestNG Data Provider with Object Array Approach:
    1. What is paramterization
    2. What is data provider (@DataProvider)
    3. What is two dimensional Object array (Object [][])
    4. Test Case parameterisation with Excel
    5. Get Data from Excel using APACHE POI API
    ~~~~Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
    ruclips.net/user/Naveen%20Au...
    Follow me on my Facebook Page:
    / naveenqtpexpert
    Let's join our Automation community for some amazing knowledge sharing and group discussion:
    t.me/joinchat/COJqZQ4enmEt4JA... Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
    ruclips.net/user/Naveen%20Au...
    Follow me on my Facebook Page:
    / naveenqtpexpert
    Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:
    t.me/joinchat/COJqZUPB02r5sB7...
    Paid courses (Recorded) videos:
    Java & Selenium Course: www.naveenautomationlabs.com/p...
    API Course: www.naveenautomationlabs.com/p... ➡️Get Our Courses✔️
    📗 Get My Paid Courses at
    Paid courses (Recorded) videos:
    Java & Selenium Course: www.naveenautomationlabs.com/p...
    API Course: www.naveenautomationlabs.com/p...
    -------------------------------
    ✔️SOCIAL NETWORKS
    Facebook: / naveenqtpexpert
    Twitter: / naveenkhunteta
    Blog: www.naveenautomationlabs.com
    --------------------------------
    Support My Channel✔️Or Buy Me A Coffee
    Paypal: paypal.me/naveenkhunteta
    Google Pay: naveenanimation20@gmail.com
    --------------------------------
    ✔️Thanks for watching!
    देखने के लिए धन्यवाद
    Благодаря за гледането
    感谢您观看
    Merci d'avoir regardé
    Grazie per la visione
    Gracias por ver
    شكرا للمشاهدة

Комментарии • 90

  • @4malayali
    @4malayali 5 лет назад +11

    I am following your videos from june 2019.. covered topic core java ->selenium basics->POM->Testng->and interview question in Testng and Selenium . And i glad to announce that i got Job in Selenium Automation with java.Augest 2019. Once Again Thanks For Your All Videos. God Bless You..

  • @chintanshah9532
    @chintanshah9532 4 года назад +2

    Thanks Naveen. This was very helpful in understanding Data Provider annotation and its implementation.

  • @vrushaligholap6647
    @vrushaligholap6647 5 лет назад

    Thank you very much for sharing very informative video on TestNG dataprovider

  • @muzaffarraja4247
    @muzaffarraja4247 3 года назад +1

    Thank you so much Naveen you really done great job, it is very helpful

  • @somashekar-5273
    @somashekar-5273 6 лет назад +1

    Thanks a lot for this video.

  • @DhivagarT
    @DhivagarT Год назад

    Superb,it works.......Thanks

  • @shakelahmed9722
    @shakelahmed9722 3 года назад +1

    Thanks a ton Boss.

  • @rohitpurandare3556
    @rohitpurandare3556 5 лет назад +2

    Thanks mate!!

  • @veganforlife4699
    @veganforlife4699 7 месяцев назад +1

    30:55 the sequence that we need to remember

  • @Mr_TravelEatWorship_Official
    @Mr_TravelEatWorship_Official 5 лет назад

    Superb naveen...tq

  • @Torkmstr
    @Torkmstr 2 года назад

    Thanks man..It helped me !!

  • @sriramnagarajanit
    @sriramnagarajanit 6 лет назад +4

    thank you so much , this was the topic I'm looking for long back :)

    • @ravik3759
      @ravik3759 6 лет назад

      please provide solution Dataprovider trying to pass one parameter but method takes 3

  • @mysterynaren
    @mysterynaren 3 года назад

    Hi Naveen, I am following many of your videos and they are really helpful, easy to understand and very informative. Can you please provide me the basic idea on automation on guidewire policy center application asap.

  • @GOKULKRISH2302
    @GOKULKRISH2302 6 лет назад

    Hi Naveen, your video is really helpful☺️, In this tutorial u hv only passed text values as parameters, Is it possible to use check box & radio buttons also, if so hw can we pass their values in excel. Thnx in advance ☺️☺️

  • @3vedinishit
    @3vedinishit 4 года назад +1

    Hi Naveen, your explanation is so simple that .. it is very easy to understand. I have doubt if i have more inputs say 7 Rows(inputs) and 11 columns, how to handle . Please explain i have tried one of your example having more inputs. but not working.

  • @pranabn6755
    @pranabn6755 3 года назад

    Thanks

  • @navjyot_ironman
    @navjyot_ironman 4 года назад +2

    Thanks Naveen !!
    My Notes on this session are :
    Problem statement : User has to read data from Excel sheet using DataProvider in TestNG framework
    Steps:
    1) Create Excel sheet to store Data
    2) Create Excel Utility to read data from Physical Excel sheet.
    3) Call Excel Utility in method of DataProvider
    4) Give the name of DataProvider to @Test Method so that it can read data from Object Array of DataProvider.
    Also you can give name to DataProvider and if its not given then it will use the method name on which @DataProvider is written.
    TestUtil.java: It has Excel sheet name here to read data. It has logic to read data from Excel sheet and store that data in Object Array.
    DataProvider is calling method in TestUtil.java and reading data and storing it in Object Array.
    @Test Login Test Method is getting data from DataProvidder and then it is printing this data one by one.
    Make sure that @Test Login Tst method has same parameters as per dimensions of Object Array i.e. it should match with number of columns in excel sheet where actual data is stored.

  • @vive121
    @vive121 5 лет назад

    Hi Naveen, thanks for posting the tutorial. I am working on 2 scenarios. Could you please suggest or create a tutorial?
    Scenario - 1 :
    1) Consider LOGIN details are common and needs to be loaded / run everytime. So I will have this details under LOGIN.xlsx
    2) Now whenever I run TC1.xlsx this will be called from inside the TC1.xlsx
    Scenario - 2:
    1) Have test cases placed in User Dir. Sequentially launch the xlsx.
    2) Ex: When TC1.xlsx is completed it should load TC2.xlsx and so on.

  • @Jayakrishna-ly3ei
    @Jayakrishna-ly3ei 2 года назад +1

    tried udemy code from morning which has 500 lines of code. i typed this code , it did the work,. if possible please add a link which has code for each and every program. Thank u so much sir

  • @MsMainhoona
    @MsMainhoona 6 лет назад +1

    Hi Naveen,
    I have a query, if the eXcel sheet have multiple type of data , why are we keeping all as string type in the data provider methid arguments, cant we keep them as they are, for ex , if its some percentage ,cant we keep the parameter as float?

  • @curious6899
    @curious6899 5 лет назад

    Sometimes there are version conflict - for example, my old script won't work with Chrome because Chrome is updated. So what combination of versions we should use for Selenium WebDriver + Chrome + Firefox + Eclipse? Which version of Eclipse works best with all?

  • @kalyanijoshi6884
    @kalyanijoshi6884 5 лет назад

    hi naveen .is it.possible to use multiple data provider in single class for different tests. I am getting a null pointer exception in case of 2nd data provider

  • @bhavinmistry9913
    @bhavinmistry9913 3 года назад

    Hi Naveen,
    Thank you for posting all the videos on Selenium and Core Java. I have gone through a lot of videos , but i found yours the best from basic to advanced methods.
    I needed your one help for this video.
    I have only 1 Column with multiple rows in the excel. How to read all that data and send it to Object.
    Should i change it to single dimensional object ?

    • @kannykanny1
      @kannykanny1 Год назад

      I think you need to still use 2 dimension object array wherein your row will increase but column will stay 0

  • @greenpeace041
    @greenpeace041 4 года назад

    Thanks Naveen : I want to pull URL also from Excel Sheet how Can I do that do I need to do 3 object array in place of two object array . Please help

  • @mohamedmabrouki6267
    @mohamedmabrouki6267 3 года назад

    Hallo Naveen ,what if there are more than two columns in my Excel table ? Thank you very much

  • @dhananjayapattnaik7428
    @dhananjayapattnaik7428 4 года назад

    Whenever I type workbook factory.create() a lot of crate method is showing so which one should I use.

  • @nehalnz1823
    @nehalnz1823 4 года назад

    Hi Naveen
    What if I don't want to fetch data repeatedly means I want to fetch particular cell value of excel then which method can be used?

  • @srabaniadhikary318
    @srabaniadhikary318 3 года назад +1

    Hi Naveen.
    How can I read Particular cells and columns data using data provider?

  • @ashuforh35
    @ashuforh35 2 года назад

    hi naveen.. really nice vdo & teachng is awsm as always.. 👌 but if we want to use same login method of login for +ve & -ve scnario with assertion how can we do it by putng assertion in it using dataprovider? can u giv a hint plz?

  • @funnysides3898
    @funnysides3898 5 лет назад

    if i dont want to execute after method each and every time i.e. closing browser each and every time, and i want to enter all the test data in one shot one by one and that too after entering one batch clearing and again entering usin for loop untill the end of the last row so how can we do that

  • @mahendratawade606
    @mahendratawade606 3 года назад

    Is possible to change dataprovider runtime or can we fetch the data from 2 sheet in single object ?

  • @sanbethel1
    @sanbethel1 4 года назад

    Hi Naveen, I have two sheets in my excel workbook. My test method is a loginTest. I am trying to use the same method and data provider for both the sheets. How can I do this? Right now I am using different data providers for different sheets
    @DataProvider(name="dealershipLoginData")
    public Object[][] getDealerLoginURLData() {
    Object[][] dealershipURLData = null;
    String excelPath=projectPath+"/src/main/resources/testData/CustomerLinks.xlsx";
    ExcelUtils excelUtils = new ExcelUtils();
    try {
    dealershipURLData = excelUtils.getTestData(excelPath, "Sheet3");
    } catch (Exception e) {
    e.printStackTrace();
    }
    return dealershipURLData;
    }
    Is there anyway I can make the sheet name as variable and then how I be able to use it in the test method?

  • @nivedithareddy9319
    @nivedithareddy9319 4 года назад +2

    Hi navven,
    Thanks for sharing, can u share if one use case is failed in above program how to handle that kind of scenarios

  • @anjanpersonal
    @anjanpersonal 4 года назад +1

    what if we have more than 2 columns data in excel, Do we still need to give 2 dimension array? if so how it works?

  • @durgaraotdr4784
    @durgaraotdr4784 Год назад

    once we saved in notepad,
    is it required to update the version of apache dependencies...

  • @userdeleted2420
    @userdeleted2420 3 года назад

    Say I have two suites, Test1.xml and Test2.xml and two Excel files, file1.xls and file2.xls. When I run test Test1.xml, it should pick file1.xls

  • @bheemeshmanikonda8181
    @bheemeshmanikonda8181 4 года назад

    Hello Naveen , if number of columns are huge , then there is a concept of store entire column data in hashmap. Anyone solution for this scenario

  • @001jyothi
    @001jyothi 4 года назад

    If we want to pass combination string integer double value then how can object array handle

  • @atulyadav958
    @atulyadav958 4 года назад

    Hello Sir,
    I am trying to use two dataprovider by this method by making the two arryalist with different static method in one class and the sheet name is different but the sheets are in same workbook but not able to pass the second dataprovider data in desired test without using dataprovider if i pass single value then the data is accepted by the webpage and the script is running by after providing the data provider the test is not executable showing the insertion error and also if i mam using the same in diffrent class again the test is not able to perform by second dataprovider but working with the firstone. Please give me some suggestion to come up with this.
    Thanks

  • @kshipra4504
    @kshipra4504 3 года назад

    If I have say 20 columns, then instead of passing 20 parameters, can't we use Hashmap? Taking all the data from Excel to Hashmap and then using it in our TC. Please suggest if you can a video supporting such example.

  • @mariapeterchrisalagose2204
    @mariapeterchrisalagose2204 Год назад

    Hi Naveen, if we have two testcases for login page and we have 2 different set of testdata(for ex 1st testcase contains testdata: Title, Name, Country and 2nd testcase contains testdata : Name, Address, PhoneNumber) then, can we access the data for these 2 testcases for login page from the same sheet Login within the excel or we need to create different sheet for the 2nd testcase ? Can you please help

  • @kannykanny1
    @kannykanny1 Год назад

    Hi Naveen- 27:24 In interview yesterday I was asked How do you read a specific row from excel? I too didn't expect this to be asked. In future can I just show them how to fetch row or do I need to show passing it to data providers too. It seems like really long answer to explain everything. Can I just show how to fetched rows and use sendkeys() to populate values rather than through data providers.. Please advise.

  • @sharithadoss8245
    @sharithadoss8245 6 лет назад +2

    Thanks for the video! I'm getting some error in Testutil - sheet methods... "The method getLastRowNum() is undefined for the type Object".. Am I missing something? Plz help me.

  • @gamingandfacts8164
    @gamingandfacts8164 3 года назад

    Hi,lets say the @dataprovider method is written in different class then how to handle it?

  • @yatindersingh2033
    @yatindersingh2033 4 года назад

    Hi Naveen, i am using your tutorials for my self learning and they are very much helpful. i was trying working on the data provider, but i am getting null point exception. Could you please help me with the same.

  • @KartikPandaVlogs
    @KartikPandaVlogs 2 года назад

    what happen if we have multi numbers of prioritized methods , then at that moment how we gonna give priority to data provider method . please explain.

  • @saikatdhar8689
    @saikatdhar8689 6 лет назад +3

    how to implement it in framework

  • @riaaggarwal6993
    @riaaggarwal6993 5 лет назад

    How to use one data provider for all test cases? And I want to pass the sheetname in data provider for all test cases.how to achieve that?

  • @nikhildevakar9155
    @nikhildevakar9155 4 года назад

    hai sir, what if i have multiple sheets in the same excel like sheet1,sheet2,sheet3 .........and i have to traverse to the third or second sheet in the same excel and get the data then the code is not working for me, it is throwing an error... please help me in this scenario

  • @iR0b005
    @iR0b005 6 лет назад +2

    Naveen can you please share the link to where you have all these files and code. The video is very helpful thanks.

    • @97Ryuuku97
      @97Ryuuku97 4 года назад

      static WorkBook book;
      static Sheet sheet;
      public static String TESTDATA_SHEET_PATH = ""
      public static void getTestData(String sheetName){

      FileInputStream file = null;
      try{
      file = new FileInputStream(TESTDATA_SHEET_PATH);
      }catch (FileNotFoundException e){
      e.printStackTrace();
      }
      try{
      book = WorkBookFactory.create(file);
      }catch(InvalidFormatException e){
      e.printStackTrace;
      }catch(IOException e){
      e.printStackTrace();
      }
      sheet = book.getSheet(sheetName);
      Object[][] data = new Object[sheet.getLastRowNum()][shet.getRow(0).getLastCellNum()];

      for (int i = 0; i < sheet.getLastRowNum();i++){
      for(int k = 0; k < sheet.getRow(0).getLastCellNum();k++){
      data[i][k] = sheet.getRow(i + 1).getCell(k).toString();
      //System.out.printlt(data[i][k]);
      }
      }
      return data;
      }

  • @JagadeeshJayachandran
    @JagadeeshJayachandran 6 лет назад +1

    HI Naveen
    How to avoid the first column from reading, for example, I have filled my first column as TC1, TC2, TC3 etc., should I remove them.

  • @nukarajubhuvana4041
    @nukarajubhuvana4041 4 года назад

    Sir i have done same as you did, but i am getting java.lang.String error..how to solve this

  • @Kranthi233
    @Kranthi233 5 лет назад +2

    By .toString() method you are converting the excel data into string to store in object array ..but I want to pass the numeric data to dataprovider ..

    • @anbu8006
      @anbu8006 4 года назад +1

      did you find the solution for your question? plz help me

  • @vpmani2659
    @vpmani2659 3 года назад

    Dear All,
    If we want to test the multiple test case with one data provider so that from excel one column for one test case could you please help me on this...

  • @munmunkundu1792
    @munmunkundu1792 3 года назад

    Hi Naveen,
    Will the Logic Implemented in the Util File get all data if we have data in more than 2 columns?

  • @sainane9138
    @sainane9138 4 года назад

    how can i get your selenium vedios (orderwise)

  • @sainiranjan40
    @sainiranjan40 4 года назад

    Hello Naveen, As I run on local I have no issues but when I upload to Azure DevOps and run remotely, build failed with below errors. I was wondering why Azure DevOps failing to download the packages? Any suggestion please!
    [INFO] Compiling 32 source files to d:\a\1\s\ExceleRATE\target\classes
    [INFO] -------------------------------------------------------------
    [ERROR] COMPILATION ERROR :
    [INFO] -------------------------------------------------------------
    [ERROR] /e:/a/1/s/ExceleRATE/src/main/java/com/qa/ExceleRATE/util/ReadExcelData.java:[8,35] package org.apache.poi.ss.usermodel does not exist
    [ERROR] /e:/a/1/s/ExceleRATE/src/main/java/com/qa/ExceleRATE/util/ReadExcelData.java:[9,37] package org.apache.poi.xssf.usermodel does not exist
    [ERROR] /e:/a/1/s/ExceleRATE/src/main/java/com/qa/ExceleRATE/util/ReadExcelData.java:[10,37] package org.apache.poi.xssf.usermodel does not exist
    [ERROR] /e:/a/1/s/ExceleRATE/src/main/java/com/qa/ExceleRATE/util/ReadExcelData.java:[18,9] cannot find symbol
    symbol: class XSSFWorkbook
    location: class com.qa.ExceleRATE.util.ReadExcelData
    [ERROR] /e:/a/1/s/ExceleRATE/src/main/java/com/qa/ExceleRATE/util/ReadExcelData.java:[20,9] cannot find symbol
    symbol: class XSSFSheet
    location: class com.qa.ExceleRATE.util.ReadExcelData
    [ERROR] /e:/a/1/s/ExceleRATE/src/main/java/com/qa/ExceleRATE/util/ReadExcelData.java:[31,34] cannot find symbol
    symbol: class XSSFWorkbook
    location: class com.qa.ExceleRATE.util.ReadExcelData
    [INFO] 6 errors

  • @cooper6470
    @cooper6470 2 года назад

    I followed the same procedure as in the video..but when I took my password in Excel as 123456..it is taking it as 123456.0 during test execution...any help?

  • @mohan201430
    @mohan201430 6 лет назад +1

    Hi Naveen
    i am getting these type of error
    SKIPPED: plLoginPage
    org.testng.TestNGException:
    Method plLoginPage requires 2 parameters but 0 were supplied in the @Test annotation.

    • @prabeshkumarbhagat2989
      @prabeshkumarbhagat2989 6 лет назад

      Go through the whole video you will get to know the solution for Your error

  • @sangeethasm6576
    @sangeethasm6576 4 года назад

    Hi i am getting error as cannot locate element as text when i use data providers

  • @aliridhohabsyi1242
    @aliridhohabsyi1242 5 лет назад +2

    Hi Naven I have follow your instruction but got the problem with java.lang.RuntimeException: java.lang.NullPointerException
    .
    I have debug it on TestUtil.java, for sheet it's null.
    Can you help me to fix this problem??
    Thanks

  • @albertobetofrias
    @albertobetofrias 3 года назад

    I run it but as soon it gets to enter the data close and show skip on the results =/, any idea hehe thanks!

  • @roliapanna8097
    @roliapanna8097 5 лет назад

    Hi Naveen! can you please share the link to where you have all these files and code. The video is very helpful thanks

    • @97Ryuuku97
      @97Ryuuku97 4 года назад

      static WorkBook book;
      static Sheet sheet;
      public static String TESTDATA_SHEET_PATH = ""
      public static void getTestData(String sheetName){

      FileInputStream file = null;
      try{
      file = new FileInputStream(TESTDATA_SHEET_PATH);
      }catch (FileNotFoundException e){
      e.printStackTrace();
      }
      try{
      book = WorkBookFactory.create(file);
      }catch(InvalidFormatException e){
      e.printStackTrace;
      }catch(IOException e){
      e.printStackTrace();
      }
      sheet = book.getSheet(sheetName);
      Object[][] data = new Object[sheet.getLastRowNum()][shet.getRow(0).getLastCellNum()];

      for (int i = 0; i < sheet.getLastRowNum();i++){
      for(int k = 0; k < sheet.getRow(0).getLastCellNum();k++){
      data[i][k] = sheet.getRow(i + 1).getCell(k).toString();
      //System.out.printlt(data[i][k]);
      }
      }
      return data;
      }

  • @AnilKumar-up5qx
    @AnilKumar-up5qx 4 года назад

    Has anybody used it successfully. Hello Naveen Sir, I used this code but i am getting a null pointer exception consistently.

  • @venkateshkv9654
    @venkateshkv9654 5 лет назад

    How to handle blank cells ??

  • @sagarsjdjfn
    @sagarsjdjfn 2 года назад

    I had 1 IMP question - how to use multiple dataprovider in one testsuit -so that i can cover multiple testcases in one. ?

  • @RKWORLD66
    @RKWORLD66 5 месяцев назад

    Sir
    how to compare two CSV files
    First contains Payments with User UID
    second contains Sum of Payment with same User UID
    I need to compare Second CSV carries Sum of Amount is matched with first csv.

  • @prashantsharma1242
    @prashantsharma1242 3 года назад

    Naveen how can I get this tetsiutil.java code?

  • @umaa2115
    @umaa2115 6 лет назад

    Hi Naveen can you share the code for Testutil class?

    • @97Ryuuku97
      @97Ryuuku97 4 года назад

      static WorkBook book;
      static Sheet sheet;
      public static String TESTDATA_SHEET_PATH = ""
      public static void getTestData(String sheetName){

      FileInputStream file = null;
      try{
      file = new FileInputStream(TESTDATA_SHEET_PATH);
      }catch (FileNotFoundException e){
      e.printStackTrace();
      }
      try{
      book = WorkBookFactory.create(file);
      }catch(InvalidFormatException e){
      e.printStackTrace;
      }catch(IOException e){
      e.printStackTrace();
      }
      sheet = book.getSheet(sheetName);
      Object[][] data = new Object[sheet.getLastRowNum()][shet.getRow(0).getLastCellNum()];

      for (int i = 0; i < sheet.getLastRowNum();i++){
      for(int k = 0; k < sheet.getRow(0).getLastCellNum();k++){
      data[i][k] = sheet.getRow(i + 1).getCell(k).toString();
      //System.out.printlt(data[i][k]);
      }
      }
      return data;
      }

  • @InduMusuvathiDevendran
    @InduMusuvathiDevendran Год назад

    how to read only one row from the excel sheet

  • @ERDheerajmann
    @ERDheerajmann 6 месяцев назад

    I do not understand why we need TDD if we are expecting same results with all credentials
    there should be approach like:
    Usertype Email pass canlogin
    valid username1 pass1 true
    invalid username1 pass1 false
    Now each test iteration should have its own validation

  • @devshah8205
    @devshah8205 2 года назад

    can i get testutil code

  • @anagosztonyi
    @anagosztonyi 3 года назад

    all the examples are simpre : email and´password. I have issues with numbers but there are no examples with them

    • @naveenautomationlabs
      @naveenautomationlabs  3 года назад +1

      With numbers also concept will remain same. No change in the code.

  • @nishantbelpande4909
    @nishantbelpande4909 2 года назад

    Hi Naveen I want to skip 2 column data from excel using data provider but don't want that column name in method as this parameter is not in use so want to skip this column is any way to handle this ?