Selenium Framework for Beginners 19 | Selenium TestNG How to get data from Excel using DataProvider

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024
  • more about Raghav - automationstep...
    Today we will learn How to get data from Excel using DataProvider of TestNG
    REFERENCES
    How to use excel for getting data
    • Selenium Framework for...
    Today we will learn
    1. How to get test data from excel
    2. How to create excel data provider function
    3. How to use testNG @DataProvider
    4. How to refer test data from DataProvider
    5. Run a sample data driven Selenium Test
    helpful tips
    Prerequisite
    Add excel reading libraries (Apache POI)
    Create functions to read data from excel
    Watch the video - • Selenium Framework for...
    How to get test data from excel
    Step 1 -Create a function to get Row Count
    Step 2 - Create a function to get Column Count
    Step 3 - Create a function to get String cell data
    Step 4 - Create a function to get Numerical cell data
    How to create Excel Data Provider function
    Step 1 - Create a new class ExcelDataProvider
    Step 2 - Create a function and create object for ExcelUtils
    ExcelUtils excel = new ExcelUtils(“excelpath”, “sheetname”);
    Step 3 - Get row and column count
    int rowCount = excel.getRowCount();
    int colCount = excel.getColCount();
    Step 4 - Run a loop to get all data in an Object Array
    How to use testNG @DataProvider
    Step 1
    Create a function and provide testNG annotation
    @DataProvider(name = “testData”)
    Step 2
    Call the excel data provider function with excel and sheet name
    Step 3
    Return the data object
    How to get test data from excel
    Step 1 Create a function and provide testNG annotation
    @Test(dataProvider = “testData”)
    Step 2 In the function arguments, get input parameters equal to the parameters in the excel file
    Step 3 Use the values in your test
    #SeleniumDataDrivenFramework #SeleniumTestNGFramework #SeleniumTraining #SeleniumBeginnerTutorials
    PLAYLISTS
    SELENIUM JAVA FRAMEWORK BEGINNERS
    • Selenium Java Framewor...
    KATALON STUDIO
    • Katalon Studio
    SELENIUM BEGINNERS
    • Selenium Beginner Tuto...
    SELENIUM TIPS
    • Selenium Tips
    SELENIUM PYTHON
    • Selenium Python
    SELENIUM BUILDER
    • Selenium Builder
    JAVA
    • Java
    JAVA TIPS & TRICKS
    • Java Tips and Tricks
    JENKINS
    • Jenkins
    JENKINS TIPS & TRICKS
    • Jenkins Tips n Tricks
    JMETER BEGINNER
    • JMeter Beginner
    JMETER INTERMEDIATE
    • Jmeter Intermediate
    JMETER ADVANCED
    • JMeter Advanced
    JMETER TIPS & TRICKS
    • JMeter Tips n Tricks
    SOAPUI
    • SoapUI
    POSTMAN
    • Postman Beginner Tutorial
    GIT & GITHUB
    • Git and GitHub
    DOCKER
    • Docker
    ROBOT FRAMEWORK
    • Robot Framework Beginn...
    WEB SERVICES (API)
    • API Web Services
    REDIS BEGINNER TUTORIALS
    • Redis Beginner Tutorials
    MAVEN
    • Maven
    MISC
    • Misc Tutorials
    TOOLS & TIPS
    • Tools and Tips
    QnA FRIDAY
    • QnA Friday
    SUNDAY SPECIAL
    • Sunday Special
    ALL PLAYLISTS
    / @raghavpal
    Like on FACEBOOK :
    / automationstepbystep
    Follow on TWITTER:
    / automationsbs
    Subscribe on RUclips :
    / automationstepbystep
    ---------- Connect with Raghav -----------
    Website - automationstep...
    LifeCharger - lifecharger.org/
    Udemy Courses - www.udemy.com/...
    Facebook - / automationstepbystep
    Twitter - / automationsbs
    RUclips - / automationstepbystep
    Like, Subscribe & Share
    You can support my mission for education by sharing this knowledge and helping as many people as you can
    _______ ONLINE COURSES TO LEARN _______
    automationstep...
    Never Stop Learning
    Raghav

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

  • @AsanAhmadli
    @AsanAhmadli Год назад +2

    It took 4 years to find instructor like you. Thanks Raghav!!!

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

      So happy and humbled to see this Asan. All the best

  • @gurpreetkaur-bx3vw
    @gurpreetkaur-bx3vw 2 года назад +1

    You are a life saver. I follow your selenium videos and honestly they are so helpful. Thanks to you for the new job I got and I recommend your videos to all my friends.

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

      So happy to hear this Gurpreet

  • @rajendrakumarnayak5103
    @rajendrakumarnayak5103 3 года назад +3

    Hi Raghav sir,
    Thank you so much for such a beautiful class you've provided for TestNG dataprovider.
    An beginner would understand easily the core concepts you've explained.
    I am readily able to run my dataprovider tests properly :)
    Thank you thank you so much Raghav sir.

  • @RajuDas-zn3gx
    @RajuDas-zn3gx 6 лет назад +4

    Hi Raghav, this is excellent explanation. Video is extremely helpful. Thank you for this video

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

      Great to know this Raju

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

    This is an awesome explanation for a really difficult concept. Thanks a ton sir for making my understanding very easy about DataProvider with TestNG.

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

    This is simply awesome...Great teaching..I am a fan of your teaching..This concept is greatly explained...Thanks Sir...🙏

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

      You're most welcome Omkar

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

    @
    Automation Step by Step - Raghav Pal :
    Excellent lesson... specially for the persons like us who are from manual testing background & quite new in automation. In my case I have to put from my excel sheet the Mobile no. (as username), Password, Confirm Password.... So while using the for loop I can't get how to pass excel.getCellDataNumber along with excel.getCellDataString... My first column is carrying the mobile number...
    for(int i=1; i

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

      Hi Neelanjan, this video will help - ruclips.net/video/B4G2tMDYjRQ/видео.html

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

    excellent

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

    Any beginner can work just by keeping your videos aside Raghav. really helpful

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

      So happy to see your message Aluri

  • @vamshivishwanath
    @vamshivishwanath 2 месяца назад +1

    At 12:07
    facing null point exception with the same code followed previoius vedio working fine

    • @RaghavPal
      @RaghavPal  2 месяца назад

      Vamshi
      will need more details.. error message, logs, code etc to troubleshoot

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

    Hi Raghav very neatly explained with points. Thanks you

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

      You're most welcome Swetha

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

    The Best available in RUclips

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

      Happy and Humbled to see this Deepu

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

    Thank you so much!

  • @bimlesh81
    @bimlesh81 4 года назад +3

    Hi Raghav - Both your videos 18 and 19 on reading data from Excel are very informative and great work as usual! In my project, we use single excel input file to store test data for the various test cases. For example, my excel input file will have 10 different rows containing test data for the different test cases - each test case row will have column names like Test Case Name, Test Data1, Test Data2....Test Data5...and finally there is a column called Execute with values 'Yes' or 'No'. How do I extract the data to my DataProvider only based on the Test Case Name and when Execute column has the value 'Yes'. The criteria here is not to extract all the data from Excel input file but only to extract data based on the test case name and execute column = Yes. Appreciate if you can give your guidance here.

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

      Hi Bimlesh, you can create scripts to read your excel and get data corresponding to the column that has Execute=Yes. This is help you - ruclips.net/video/B4G2tMDYjRQ/видео.html

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

    Thanks!

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

      Thanks for the support Siddharth

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

    Thank you so much, your videos are very helpful!

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

      You're very welcome Karima

  • @Vikram.G
    @Vikram.G 2 года назад

    Thank you for making such videos... can u make video upon the how to execute nigative test... like when we enter worng id,pass then it should display error ... like this

    • @RaghavPal
      @RaghavPal  2 года назад +1

      Hi Vikram, I will plan

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

    Hi raghav, good explanation
    Kindly know which method we can used for alphanumeric values while fetching the data from xlxs

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

      Hi Karishma, this can help - ruclips.net/video/B4G2tMDYjRQ/видео.html

  • @dasarianveshitha7386
    @dasarianveshitha7386 6 месяцев назад +2

    When i run the dataprovider class getting index 1 out of bounds for length 1

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

      Ammu
      The "index 1 out of bounds for length 1" error typically occurs when you're trying to access an element at an index that doesn't exist in an array or collection. Let's troubleshoot this issue in the context of TestNG and Selenium.
      Here are some common reasons for encountering this error and potential solutions:
      1. Data Provider Mismatch:
      - The error message you provided mentions a data provider mismatch. This usually happens when the number of parameters in your test method doesn't match the number of data provider arguments.
      - Ensure that the number of parameters in your test method matches the number of columns (arguments) returned by your data provider.
      - Verify that the data provider method returns the correct number of arguments for your test method.
      2. Data Provider Arguments:
      - Check the data provider method (`dpMethod` in your case). It should return a 2D array (or an iterable collection) with the correct number of columns.
      - Each row in the array corresponds to a set of arguments for your test method.
      - Make sure the data provider method returns the expected number of columns (parameters) based on your test method signature.
      3. Test Method Signature:
      - Your test method (`myTest` in your example) should have the same number of parameters as the data provider method.
      - Verify that the test method signature matches the data provider arguments.
      4. Example Fix:
      ```java
      import org.testng.annotations.DataProvider;
      import org.testng.annotations.Test;
      public class DProvider {
      @DataProvider(name = "data-provider")
      public Object[][] dpMethod() {
      return new Object[][] {
      {2, 3, 5},
      {5, 7, 9}
      };
      }
      @Test(dataProvider = "data-provider")
      public void myTest(int a, int b, int result) {
      int sum = a + b;
      // Your test logic here
      // ...
      // Assert.assertEquals(sum, result);
      }
      }
      ```
      - In this example, the data provider returns three columns (arguments), and the test method `myTest` accepts three parameters.
      5. Check Excel Data:
      - If you're reading data from an Excel file, ensure that the data is correctly formatted and matches the expected number of columns.
      - Verify that the Excel sheet contains the right number of columns for your test method.
      Remember to validate the data provider, test method, and data source (Excel, CSV, etc.) to ensure consistency in the number of arguments.
      .

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

    Clear explanation.. I am able to login into my application with username and password but I m not able to get the next sheet inputs .. how to include more than one sheets?

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

      Hi Sathya, you will need to call the sheet in your code and then get the contents
      This can help ruclips.net/video/B4G2tMDYjRQ/видео.html

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

    Very Well Explained

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

      Thanks for watching Sabuhi

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

    Hi Raghav pal, how are you?
    I have another question to you : )
    Scenario - This is how my excel looks like:
    1° column - Customer name
    2° column - Customer type
    So there are many lines with this information!
    -------------------------------------------------------------------------
    My automation will not need "ALL" the excel information. lets say that the automation will find the exact customer name in the web application. Then with this information (Customer name) I need to read the excel to discover the Customer type.
    My question is:
    - How can I search for the exact meet customer name in the excel (using Apache POI ore any other API).
    - After search, discover the index from the cell in the column 1
    - And look to the same index but in the column 2
    - Bring the content from the cell - column 2- and print it
    than I will be able to decide what to do
    E.g.
    If ( CustomerName == partner)
    {
    Send this email
    }Else{
    Send a different email.
    }
    Can you help me with that ???
    Thank you so much, your videos always help me a lot!!!!

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

      Hi Gilson, once you are able to read and get the content from excel, you can add your conditions, for example if the customer name is found, record the row number and get value from the corresponding email column.
      This can help you - ruclips.net/video/B4G2tMDYjRQ/видео.html

  • @AnilKumar-sf4em
    @AnilKumar-sf4em 4 года назад +1

    Hi Raghav,
    Thanks, this video has good information.
    I have a 10 excel sheets in a workbook, each excel having one testcase(20rows). How to get all sheets data and execute 10 testcases, Please help.

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

      Hi Anil, you will have to give the logic in your code. You can either name the sheets same as the test cases and in the code switch to the sheet by test case name and then get the data.

  • @user-hm9cu3tl9y
    @user-hm9cu3tl9y 9 месяцев назад

    hello sir its really this made me to learn very easily ..can you help me to where is should declare file path without hardcoding..i am making my own framework

    • @RaghavPal
      @RaghavPal  8 месяцев назад +1

      Manish
      Absolutely! Declaring file paths without hardcoding in your Selenium Java project for a custom framework is crucial for maintainability and flexibility. Here are some options to consider:
      *1. Environment Variables:*
      * Store file paths in environment variables like `TEST_DATA_DIR` or `CONFIG_FILE_PATH`.
      * Access them within your code using `System.getenv(variableName)`.
      * This approach is platform-independent and easily configurable during execution.
      *2. Resource Files:*
      * Place configuration files like `data.properties` or `config.yaml` inside your project's `resources` directory.
      * Access them using `ClassLoader.getSystemResourceAsStream(fileName)`.
      * This keeps your code clean and files readily available at runtime.
      *3. Classpath Scanning:*
      * Annotate your configuration files with a custom annotation like `@TestDataFile`.
      * Use a custom scanner to identify all files with that annotation at runtime.
      * This allows for dynamic discovery of configuration files without hardcoding paths.
      *4. Dependency Injection:*
      * Define an interface for fetching file paths and inject its implementation during runtime.
      * Different implementations can provide paths based on environment or configuration files.
      * This promotes loose coupling and allows for easy switching between different file sources.
      *Additional Tips:*
      * Use relative paths within your code whenever possible to avoid hardcoding absolute paths.
      * Implement a utility class to handle file access and path resolution for consistent usage across your framework.
      * Consider using libraries like Apache Commons IO or Jasypt for advanced file handling and decryption.
      By choosing the approach that best suits your needs and coding style, you can ensure your Selenium Java framework is flexible and adaptable, with file paths declared dynamically without hardcoding.
      Remember to choose an approach that balances readability, maintainability, and security based on your specific project requirements.

    • @user-hm9cu3tl9y
      @user-hm9cu3tl9y 8 месяцев назад

      Here i completd the entire series of TestNg i dont know how to appreciate all your efforts i have no words to praise you....Thank you soo much for Valuable replay and your informative words...sir i want to show my framework which i have designed by taking all your informative videos. .i want to share my framework . i want to check wth whether i am follwing the right way sir...sir can you share me your contact @@RaghavPal

    • @RaghavPal
      @RaghavPal  8 месяцев назад +1

      I may not get enough time to do a personal review, but if you have followed all the steps and understood the concept. you are good to go,.. can also try more examples online.. Best wishes Manish

    • @user-hm9cu3tl9y
      @user-hm9cu3tl9y 8 месяцев назад

      Thank you sir...@@RaghavPal

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

    Hi Raghav , I m getting this error after duration 12:24
    -------------------------------------------------------------------------------------------------------------------------
    No of rows:2
    No of columns:2
    Admin
    Admin
    Cannot get a STRING value from a NUMERIC cell
    null
    null
    java.lang.IllegalStateException: Cannot get a STRING value from a NUMERIC cell
    at org.apache.poi.xssf.usermodel.XSSFCell.typeMismatch(XSSFCell.java:1035)
    at org.apache.poi.xssf.usermodel.XSSFCell.getRichStringCellValue(XSSFCell.java:390)
    at org.apache.poi.xssf.usermodel.XSSFCell.getStringCellValue(XSSFCell.java:342)
    at Utils.ExcelUtils.getCellDataString(ExcelUtils.java:66)
    at Utils.ExcelDataProvider.testData(ExcelDataProvider.java:23)
    at Utils.ExcelDataProvider.main(ExcelDataProvider.java:12)

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

      Hi, this should help you - ruclips.net/video/B4G2tMDYjRQ/видео.html

    • @vamshivishwanath
      @vamshivishwanath 2 месяца назад +1

      @nistan5404 AT 12.24 iam getting null point exception please help buddy

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

    Hi Raghav,
    Excellent Tutorial!! Excellent Effort!!
    Raghav how to handle empty cell(blank data) in dataprovider it throws org.testng.internal.reflect.MethodMatcherException:

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

      Hi Bharathi, hope this can help - ruclips.net/video/B4G2tMDYjRQ/видео.html

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

    Hi Raghav:
    It is a good video for DataProvider. One question what if our requirement is reading cell data from all rows instead from first row? How to dynamically give the row counter for for getColNumber method?
    or Can we assume that the no of columns are equal to all the rows as it was for first row? Is this good approach?

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

      Hi Keerthi, this will help - stackoverflow.com/questions/41503897/how-do-i-retrieve-a-specific-row-of-data-from-a-testng-dataprovider

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

    @RaghavPal could you explain me if Excel sheet having string and numerical data using data provider concept with data formatter.

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

      Hi Ravi
      **Data provider** is a concept in automation testing that allows you to store test data in a centralized location. This makes it easy to reuse test data and to keep track of changes to the data.
      **Data formatter** is a tool that can be used to format test data. This can be useful for converting data types, removing special characters, and other tasks.
      To use data provider and data formatter with Excel sheet having string and numerical data, you can follow these steps:
      1. Create an Excel sheet that contains the test data.
      2. Identify the columns in the Excel sheet that contain string and numerical data.
      3. Create a data provider that reads the data from the Excel sheet.
      4. Create a data formatter that formats the data from the data provider.
      5. Use the data provider and data formatter in your automation scripts.
      Here is an example of how to use data provider and data formatter with Excel sheet having string and numerical data:
      ```
      import { DataProvider, DataFormatter } from 'some-data-provider-library';
      const dataProvider = new DataProvider('my-excel-sheet.xlsx');
      const dataFormatter = new DataFormatter();
      const testData = dataProvider.getData();
      const formattedData = dataFormatter.formatData(testData);
      // Use the formattedData in your automation scripts.
      ```
      I hope this helps

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

      @@RaghavPal thanks for the information

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

    Hi sir, plz make a video on how to write particular syso to excel using selenium testng

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

      I will plan on this Anitha, this can also help, ruclips.net/video/B4G2tMDYjRQ/видео.html

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

    Hi Raghav, I am learning alot by referring your videos.Thankful to you for this.I followed your code and was able to print 2 sets of data but I entered 2 rows in my TestData and 3 test results ,cosole is showing with 1 set of "Null data" .Plz help me in understanding where did I go wrong?

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

      Hi Monica, most probably if you are using a loop, it is going until a row or cell with no data, you can try printing the row, col number to confirm

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

      @@RaghavPal I will retry it Raghav Sir ,One more help I need, you have demonstrated using this method in the same class ie testutils but if I am using it in some other class in a framework. There are 2 classes basically we have created and I am looking for one utility code which we can keep in my testutil file and then call the method by creating its object.

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

      This can help Monica - ruclips.net/video/B4G2tMDYjRQ/видео.html

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

    @raghav well done mate. another clear instruction set.i paid for wisdom training (qtpselenium)and its a waste. only after watching your videos i was able to understand selenium/java concepts. i have question related to SOAPUI(Free version) groovy script..What version of POI we need to use with soap? I am try to use same excel sheet for soaui and selenium to run bother in go. please advice..

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

      Hi Chan, glad to know it helped. You should be able to use latest poi jars. Pls check.

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

    Hello Raghav , Could you please do for us a training about UFT and Ranorex please ?

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

      Hi Taibouch, I will add to my to do list

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

    Rather than creating new method for @Dataprovider can we also use that below method which is already returning object array of data??

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

      Hi Divyang, You can make any method as TestNG DataProvider that is returning the data you require.

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

    Hi Raghav, I'm a fan of your Selenium tutorial. Thank you very much for your lessons. By the way, I'm having a problem with your DataProvider lesson. I also wanted to get the empty cell but selenium is throwing me "java.lang.NullPointerException" i appreciate your help. Your code and my code are the same. Thank you.
    public String getCellDataString(int rowNum, int colNum) {
    String cellData = null;
    try {
    cellData = sheet.getRow(rowNum).getCell(colNum).getStringCellValue();

    }catch(Exception exp){
    System.out.println(exp.getMessage());
    System.out.println(exp.getCause());
    exp.printStackTrace();
    }
    return cellData;
    }

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

      Hi Francis, this can help - ruclips.net/video/B4G2tMDYjRQ/видео.html

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

      @@RaghavPal Hi Raghav, Thank you for the link that you that you gave me, I watched it but it doesn't have how to get an empty/blank cell. :(

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

      Okay, for now pls try online help

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

    Hi Raghav, I keep getting an error - cannot get a string value from numeric cell. what is the best way to avoid that error?. I thought if i change the format in excel to text it will consider the value as string. But after changing that i am still getting that error. IS there a way to change the cell format to string and not worry about this error?

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

      Hi Puneet, if your data is numeric, you will need to use a diff function to read excel. Check this - ruclips.net/video/B4G2tMDYjRQ/видео.html

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

      @@RaghavPalThank you. i was able to proceed with this.

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

    Hi Raghav, Thanks for responding to other query. However I am stuck at another place now. What i am trying to do is . Using data provider - can i run multiple test methods? Lets say if i have 3 test methods in my test case. And i want to read data provider then go to first test run it , move to second test and then third and after that i want to read 2nd row from data provider. However it is looping all the rows for first test and then second and then third. What will be the solution for this?

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

      Hi Puneet, I will need to confirm this with a hands-on, Can check some online examples too

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

    Hello Raghav, can you please guide on how to print this data based on the execution flag i.e yes or no ,means printing only the set of data we require?

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

      Hi Satyawan, you will need to create a custom function for this

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

      @@RaghavPal is is possible for you to give a short idea on how it is possible? Would be very helpful

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

    One query: If I declare a dataProvider in a test class, then all the @test method must use that dataprovider?? If not, then how to ignore it? I have tried but those @test get failing. If possible, please suggest. Thanks

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

      Hi Sanjib, will need to check on this, can try some online examples meanwhile

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

    how to make a framework for selenium testng(using dataprovider) for keyword driven framework?
    same thing as in the vedio but for keyword driven

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

      Hi Sandy, the testNG concepts and methods remain same there too. You can try and check some examples online

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

      @@RaghavPal i have multiple test cases under single excel sheet. i am finding difficult in reading excel by test cases and executing using testng(parallel execution)

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

      Ok, I will plan a session, for now try to see some online examples

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

      @@RaghavPal Thank you very very very much bro
      can you please plan a session as early as possible
      at last your videos' are awesome bro

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

    Can we Input the data from dataprovider directly into methods calls in @Test methods,

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

      Hi Ahsan, the process shown in the video is the ideal way, I have not tried other ways and will need to check, You can give it a try and see what happens

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

    Hi Raghav, I want to pass different Dropdown values for different sets using Dataprovider from excel sheet, but it is always taking the values of first row. Could you please suggest how to input different dropdown values using dataprovider. Scenario: 5 users having different birth_dates which will be filled using dropdown and values are coming from excel.

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

      Hi Nitin, pls check this
      stackoverflow.com/questions/41503897/how-do-i-retrieve-a-specific-row-of-data-from-a-testng-dataprovider

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

    Hi Ragav in this video (26.42 sec) you are entering 3 different data sets but without click Login button , how can we validate those data sets without click login, we should click and validate right ? what is way to improve code more

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

      Yes, this was just for example to show how to get data from csv

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

      @@RaghavPal Thanks and how can I do that click and validate?

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

    Hi Raghab, i am trying to run data provider as per ur video but i added below in xcel_reader utility
    Object data;

    if (cell.getCellTypeEnum()==CellType.NUMERIC){

    data=sheet.getRow(rownum).getCell(columnnum).getNumericCellValue();
    System.out.println(data);

    }

    else {
    data=sheet.getRow(rownum).getCell(columnnum).getStringCellValue();
    System.out.println(data);

    }
    return data;

    }
    }
    *****************8888
    in the main class from which i am trying to run ,
    public class xceldatautility {
    public static Xls_Reader r;
    public static void main(String[] args) throws InterruptedException {
    xceldatautility x=new xceldatautility();
    x.getdataexcel();
    }
    public Object[][] getdataexcel(){
    r=new Xls_Reader("mysheet", "C:/Users/Abhij/Documents/mydata.xlsx");
    int row=r.getRowCount();
    int col=r.getColCount();
    Object [][] data= new Object[row][col];

    for(int i=0;i

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

      Hi, can you pls check and compare with this - ruclips.net/video/B4G2tMDYjRQ/видео.html

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

    Why you create getData function?. We can provide @DataProvider annotation above Object [][] test Data() function itself right? Please answer

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

      Hi, I believe have used @DataProvider in this or some other video, I will check

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

    Hi Raghav!! 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.

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

      Hi Kshipra, yes you can use

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

      @@RaghavPal Thanks for prompt reply. A video supporting this alternative/scenario is much awaited!!

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

    Hi , If i create an Object [][] fun in the base class and but I want to fetch the data from excel in another class using page factory, how to do it? please help

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

      Hi Rashmi, will do a session, can check some examples too

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

    can we use testdata method as dataprovider? because we just calling that method in getdata method so

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

    Hi Sir, I had the requirement similar to the one explained in the video. I just want to understand how do we integrate this data provider and method with the extent report as when we integrate the same with Listener Class then for each row same method will be running and in extent report same method name will be printed for every row execution. I wanted to know how do we print any parameter name which we are getting through excel as a Test Name. Thanks in advance. Your video was really helpful for my development but I am stuck at Extent Report. I am very new to framework development.

    • @RaghavPal
      @RaghavPal  2 года назад +1

      Hi Chitra, I will plan a session on this, for now can try some online examples

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

      @@RaghavPal I have tried lot of options but I am not finding any solutions. For now I am just adding random number along with method name

    • @RaghavPal
      @RaghavPal  2 года назад +1

      I will get some info, will update here

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

      ​@@RaghavPal Sir did you get any information for the same ?

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

    Hi Raghav,
    I followed your way to read the data from excel and its working fine, but i am facing issue only when I am trying to read numeric values. could you provide the solution for it.

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

      Hi Lakshmi, Pls check this - ruclips.net/video/B4G2tMDYjRQ/видео.html

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

      @@RaghavPal Thanks Raghav, It helped me to resolve the issue

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

    Could you please help me how to read numeric and string Excel data using data provider concept

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

      Hi Ravi
      To read numeric and string Excel data using data provider concept in TestNG, you can use the following code:
      ```java
      import org.testng.annotations.DataProvider;
      import org.testng.annotations.Test;
      public class DataProviderTest {
      @DataProvider(name = "data")
      public Object[][] getData() {
      return new Object[][] {
      {1, "one"},
      {2, "two"},
      {3, "three"},
      };
      }
      @Test(dataProvider = "data")
      public void testDataProvider(int number, String text) {
      System.out.println("number = " + number);
      System.out.println("text = " + text);
      }
      }
      ```
      This code will read the data from the Excel file and pass it to the test method as a 2-dimensional array. The first element in the array is the numeric data, and the second element is the string data.
      To run the test, you can use the following command:
      ```
      mvn test -Dtest=DataProviderTest
      ```
      This will run the `DataProviderTest` class and the `testDataProvider` method. The `testDataProvider` method will be executed three times, once for each row in the Excel file.
      Here are some additional details:
      * The `@DataProvider` annotation is used to define a data provider.
      * The `@Test` annotation is used to define a test method.
      * The `getData()` method is used to get the data from the Excel file.
      * The `testDataProvider()` method is used to run the test.
      I hope this helps

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

      @@RaghavPal thanks for the information

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

    thanks

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

    Raghav thanks for the easiest approach this was what i wanted but i have a doubt that if we have to test suppose by entering only username, so in this case we will keep password cell as blank but on keeping cell blank nullpointer is thrown so can we use like " " in password field instead of leaving it as blank will it work properly???

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

      Hi Keshav, thanks for the message. You can try looking at how to get empty string from excel in java

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

      Hi Raghav, I will try and let u know whether it will work or not

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

      Raghav, i was also facing one difficulty in reading numeric values from cells as if in testdata method we write getstringcelldata() method so for cells having numeric values it gives us error that " cannot read string value from numeric cell" so in this case do we have to check the cell data type in the function getnumericcell() in the excel reading class or we need to check this condition in testdata function and secondly please tell how to check the datatype of cell??
      Please help

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

      yes for numeric values you will need to use getNumericCellValue(). It is explained in the previous video - ruclips.net/video/CV3SOorFydE/видео.html
      For doing action as per the data type of cell you can see a solution here - stackoverflow.com/questions/6508203/when-getting-cell-content-using-apache-poi-library-i-get-both-cannot-get-a-num

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

    Hello, hope you’re doing good
    I have a query how can we process the data if the columns have string as well as numerical values
    I tried different ways but always get an error cannot get a NUMERIC value from string cell

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

      Hi Yukti, pls check this ruclips.net/video/B4G2tMDYjRQ/видео.html

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

    Excellent but explanation is very fast please try to reduce Thanks

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

      Noted, for now you can decrease the speed from the player settings

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

    Hello Raghav, i went through video selenium framework for Beginner 18 and it work perfectly for me. i went and tried beginner 19 and my for loop doesnt work. it doesnt gives me error but when i checked by debugging the script it shows me it goes to for loop and than skips it out what could be possible problem?

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

      Hi Salim, will need to check logs for this

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

      @@RaghavPal Thanks a lot Raghav for your help it did workout.

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

    Hello, How to fetch data from excel which contains both string and numerical value....(Example : admin123)....because I am getting error...
    java.lang.IllegalStateException: Cannot get a STRING value from a NUMERIC cell

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

      Hi Manjusha, you can use the function geNumericCell value, it is shown here ruclips.net/video/CV3SOorFydE/видео.html

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

    Hi Raghav, sometimes it could be very helpfull to compare my actions and code with your. Do you have the whole prodject somewhere on github?

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

      You can get from github github.com/Raghav-Pal/SeleniumJavaFramework1 There is a video in the playlist on git

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

    sir I'm facing this issue
    [public void ExcelWork.ExcellDataProvider.test1(java.lang.String,java.lang.String) throws java.lang.Exception] has no parameters defined but was found to be using a data provider (either explicitly specified or inherited from class level annotation).
    Data provider mismatch
    Method: test1([Parameter{index=0, type=java.lang.String, declaredAnnotations=[]}, Parameter{index=1, type=java.lang.String, declaredAnnotations=[]}])

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

      Hi Yogesh, Pls check the video again, if you are using data provider you need to provide the parameters in the function. Also check the spelling and syntax again

  • @RajuDas-zn3gx
    @RajuDas-zn3gx 6 лет назад

    Towards the end of video u had written selenium program. For three data there may be few valid login credentials and few invalid. In the same script how to implement different assertion statement for different scenarios?

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

      In case the scenario is different than of course you will need different Test Cases for it.

    • @RajuDas-zn3gx
      @RajuDas-zn3gx 6 лет назад

      Do you have any video for this or r u planning to make some video for the same scenario? It will help a lot to understand to approach to achieve this scenario

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

      will do it soon

    • @RajuDas-zn3gx
      @RajuDas-zn3gx 6 лет назад +1

      Thank you so much. Waiting for your video

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

    Hi Raghav...if I HV testng, cucumber,POM, data driven using excel in my framework...wat type of framework will it be called

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

      More likely a hybrid framework

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

      @@RaghavPal thanks Raghav ,still.have doubt hw we called it as a hybrid as hybrid is data driven + keyword .. Correct me if I am wrong

    • @RaghavPal
      @RaghavPal  5 лет назад +1

      Yes, so in your framework you are using cucumber can better call it BDD cucumber Data driven.

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

    Great job but please activate automatic subtitles, thanks

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

      Hi Canal, mostly videos get the subtitles automatically. Some videos do not get due to audio issues. I will check on this again

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

    When I run the tesng excel dataprovider I am getting Launching excel dataprovider has encountered a problem reference to undefined variable name

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

      Ammu
      1. Undefined Variable Name Error:
      - This error typically occurs when TestNG tries to resolve a variable name (such as an environment variable or system property) but cannot find it.
      - It might be related to how TestNG handles environment variables or system properties during test execution.
      2. Possible Solutions:
      - Here are some steps you can take to resolve this issue:
      - 1. Disable System Property Variables:
      - In Eclipse, navigate to Preferences → TestNG → Maven.
      - Uncheck the option for systemPropertyVariables.
      - This step ensures that TestNG doesn't rely on system properties during test execution¹.
      - 2. Enable Environment Variables:
      - Check if the option for environmentVariables is enabled in your TestNG configuration.
      - Navigate to Preferences → TestNG → Maven and ensure that environmentVariables is checked.
      - If it's disabled, enable it and try running your tests again¹.
      - 3. Clear Cached Data:
      - Sometimes cached data can cause unexpected behavior.
      - Clear any cached responses or temporary files related to your TestNG project.
      - Restart Eclipse and try running your tests again.
      - 4. Verify Excel Data Provider:
      - Double-check your Excel data provider method.
      - Ensure that the method name matches the one specified in your TestNG test class.
      - If the method name is not explicitly specified, TestNG uses the method name as the data provider name by default³.
      - 5. Check Excel Formulas and References:
      - If your Excel file contains formulas or named ranges, verify that they don't have errors (such as #N/A, #REF!, etc.).
      - Incorrect formulas or references can cause issues with data providers².
      ..

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

      Thank you 🙏

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

    Hi, Raghav
    After trying your code, I am getting " NegativeArraySizeException " in Test Data method on line
    Object data[][] = new Object[TotalRowCount -1][TotalColumnCount];
    Can you help me with this ?

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

      Hi Rajat, Sorry for late reply, NegativeArraySizeException occurs whenever an application tries to create an array with negative size.
      For example, whenever we assigned the negative size to an array.
      int[ ] arr=new int[-10]; , Here the array size is -10 i.e., negative size.
      You can try to print the TotalRowCount. I doubt you are getting a 0 value there

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

    Hai I'm facing an issue , how to register a company using JSON request in beta. I want to register ten company with different roles. How to register. Here beta means production environment. Is it possible to do a API or selenium how register 10times quickly .. can you please which approach I have follow.

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

      Hi Pratheep, so basically you need to run a test or scenario with diff test data. You can do it through excel or directly, Can use testng. This will help - ruclips.net/video/DDQbS9cy9bY/видео.html

  • @wasimakram-nz5gq
    @wasimakram-nz5gq 4 года назад

    Hi Raghav How to find that the data from Excel is String Interger or Blank space

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

      Hi, this can help - ruclips.net/video/B4G2tMDYjRQ/видео.html

    • @wasimakram-nz5gq
      @wasimakram-nz5gq 4 года назад

      Automation Step by Step - Raghav Pal if u have do any Mini project with all Concepts can u please share me link so it is very useful for me

    • @wasimakram-nz5gq
      @wasimakram-nz5gq 4 года назад

      Automation Step by Step - Raghav Pal
      For(int i=0; i

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

      because the count starts from 0 and not 1

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

    How to get URL from From Single row row have more than 100 URLs one by one open this url and perform our test case

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

      Hi Ashish
      To get URLs from an Excel sheet and open each URL one by one for testing in Selenium Java framework with TestNG, you can follow these steps:
      1. Read the Excel sheet: Use a library like Apache POI to read the Excel sheet and extract the URLs. Here's an example code snippet to read URLs from an Excel file:
      ```java
      import org.apache.poi.ss.usermodel.*;
      import org.apache.poi.xssf.usermodel.XSSFWorkbook;
      import java.io.FileInputStream;
      import java.io.IOException;
      public class ExcelUtils {
      public static Object[][] getURLsFromExcel(String filePath, String sheetName) throws IOException {
      FileInputStream fis = new FileInputStream(filePath);
      Workbook workbook = new XSSFWorkbook(fis);
      Sheet sheet = workbook.getSheet(sheetName);
      int rowCount = sheet.getLastRowNum() - sheet.getFirstRowNum();
      Object[][] data = new Object[rowCount][1];
      for (int i = 1; i

  • @wasimakram-nz5gq
    @wasimakram-nz5gq 4 года назад

    Hi Raghav i have written 5Testcases and iam reading username and password from excel first time iam taking correct credentials second time iam taking wrong credentials , while running first time only one test case is executing remaining not running, can you please suggest anything overcome this problem. While i am giving only one data in excel then it is executing all 5 testcases

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

      Hi Wasim, not sure why exactly this is happening, Pls check your loop again and refer all the steps again with the video

    • @wasimakram-nz5gq
      @wasimakram-nz5gq 4 года назад

      Thanks for your reply

    • @wasimakram-nz5gq
      @wasimakram-nz5gq 4 года назад

      I need your help like i have username and password in excel i need to fetch only valid user and password from Excel that to both should be in same row ,and send those value in proper webelement, i try many times not getting exact logic can you please help me to overcome this. Thanks in advance

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

      You can do that and code accordingly. Can check this too ruclips.net/video/B4G2tMDYjRQ/видео.html

    • @wasimakram-nz5gq
      @wasimakram-nz5gq 4 года назад

      Automation Step by Step - Raghav Pal Thanks for reply

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

    Hi Bro,
    How can we use the @DataProvider in the large data set?

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

      Hi Mani, the process should be the same. Just to avoid a lot of I/O operations with file, I will suggest to get data in memory using collections like maps, lists etc and then use it.

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

    Hi Raghave,
    Is this the same for appium?

    • @RaghavPal
      @RaghavPal  5 лет назад +1

      Yes, it will work on appium projects too

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

    Hi Raghav, I have data.xlsx with 3 rows including header, but when i run my code, I get the below error --- Could you help me here
    No of columns: 2
    No of rows: 3
    FAILED: test1
    org.testng.internal.reflect.MethodMatcherException:
    [public void utils.ExcelDataProviderMain.test1(java.lang.String,java.lang.String)] has no parameters defined but was found to be using a data provider (either explicitly specified or inherited from class level annotation).
    Data provider mismatch
    While this runs correctly when i have 2 rows including the header. Below is the result
    No of columns: 2
    No of rows: 2
    janisha--admin234
    PASSED: test1("janisha", "admin234")

    • @RaghavPal
      @RaghavPal  2 года назад +1

      Hi Raj, check this stackoverflow.com/questions/45998857/data-provider-mismatch-in-selenium-with-testng

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

      @@RaghavPal Thank you Raghav Sir, definitely this will help me. Once again thanks for quick reply.

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

    What if I define the data provider in a class and place the test in other class. what I should do? could you show me a sample, please?

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

      Hi Emad, you should be able to import and use it.

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

    Hello Raghav, I am getting error Cannot get a STRING value from a NUMERIC cell . Could you please help us how to get a STRING value from a NUMERIC cell in

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

      Hi Sanket, you will need to use a diff func. Pls check this
      stackoverflow.com/questions/30125465/cannot-get-a-text-value-from-a-numeric-cell-poi
      stackoverflow.com/questions/27688250/how-to-read-numeric-values-from-excel-in-java

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

      @sanket
      i had same issue. easiest way is change data type at excel sheet. set everything to text.

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

    it can't read numeric data from excell .how can solve!

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

      Iffat
      Pls check this: ruclips.net/video/B4G2tMDYjRQ/видео.htmlsi=OoKtCiP-qZQX1Dc2

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

    If data have 20 fields. How to handle it??

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

      You can create 20 columns in your file and use them as needed in your script

  • @sumityadav-zu2gu
    @sumityadav-zu2gu 4 года назад

    One problem is coming in your code. Cannot get a string value from numeric cell. Please help

    • @sumityadav-zu2gu
      @sumityadav-zu2gu 4 года назад

      ??

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

      Hi Sumit, sorry for late reply. This will help - ruclips.net/video/B4G2tMDYjRQ/видео.html

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

    Hi bro, i'm trying to automate using DDT. I got an error here. when i am using invalid user name and password its working fine. but when i'm using an valid email its getting an error. i found an error but i don't know how to fix. Boolean data type is capturing the error Modal is Displaying or not, if displayed the flow is working. if the modal is not display , its not going to logout. boolean is showing null. another problem is Testng is not working Before and After methods.
    package com.tg.Testcases;
    import java.awt.AWTException;
    import java.io.IOException;
    import java.util.IllegalFormatException;
    import java.util.concurrent.TimeUnit;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.support.PageFactory;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;
    import org.testng.Assert;
    import org.testng.annotations.*;
    import com.tg.Pages.LoginPage;
    import com.utility.ConfigReader;
    import io.qameta.allure.Description;
    import io.qameta.allure.Severity;
    import io.qameta.allure.SeverityLevel;
    import io.qameta.allure.Story;
    public class LoginValidation {
    public static WebDriver driver;
    ConfigReader config;
    LoginPage login;
    ListofRoleSelection roleSelection;
    @BeforeMethod
    @Severity(SeverityLevel.BLOCKER)
    @Description("Test Case Description: Verify Base Setup")
    @Story("Story Name: To check Base Setup File Configuration")
    public void setUp1() throws IOException, InterruptedException {
    config = new ConfigReader();
    System.setProperty("webdriver.chrome.driver", config.getChromePath());
    driver = new ChromeDriver();
    driver.manage().timeouts().pageLoadTimeout(50, TimeUnit.SECONDS);
    driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
    driver.manage().window().maximize();
    driver.get(config.getUrl());
    String actualUrl = config.getUrl().trim();
    String expectedUrl = driver.getCurrentUrl();
    System.out.println("The Expected URL is : " + " " + expectedUrl + "... And... " + "The Actual URL is : " + " "
    + actualUrl);
    Assert.assertEquals(expectedUrl, actualUrl);
    }
    @DataProvider(name = "getDataFromExternalFile")
    @Severity(SeverityLevel.BLOCKER)
    @Description("Test Case Description: Verify getting UserName and Password from Excel Sheet ")
    @Story("Story Name: To check Excel Sheet Configuration")
    public static Object[][] getExcelData() throws IllegalFormatException, IOException, InterruptedException {
    ReadLoginCredentials getLoginData = new ReadLoginCredentials();
    return getLoginData.readXLSFile("C:\\Users\\Pradeep\\Documents\\New_Excel.xlsx", "Sheet2");
    }
    @Test(priority = 1, dataProvider = "getDataFromExternalFile")
    @Severity(SeverityLevel.BLOCKER)
    @Description("Test Case Description: Verify getting UserName and Password from Excel Sheet is Inserted or Not ")
    @Story("Story Name: To check User able to Login Successfully")
    public void verifyValidLogin(String UserEmailId, String userPassword)
    throws IOException, InterruptedException, AWTException {
    login = PageFactory.initElements(driver, LoginPage.class);
    login.enterEmailData(UserEmailId);
    login.enterPasswordData(userPassword);
    System.out.println("---->" + UserEmailId);
    System.out.println("---->" + userPassword);
    login.loginButton();
    // Thread.sleep(1000);
    try {

    boolean loginPageErrorModal = login.invalidUserNamePasswordModalAlert().isDisplayed();
    System.out.println("loginPageErrorModal" + loginPageErrorModal);
    if (loginPageErrorModal == true) {
    System.out.println("~~~~~~Invalid Credential~~~~~~");
    String InvalidLogin = login.invalidUserNamePasswordErrorMessage().getText();
    if (InvalidLogin.contains("Invalid Username/Password")) {
    System.out.println("Login Error Message is :" + " " + InvalidLogin);
    login.invalidUserNamePasswordOKButton().click();
    }
    else {
    System.out.println("test");
    }
    } else {
    System.out.println("~~~~~~Login Successfully~~~~~~");
    logOut();
    }
    }
    catch (Exception e) {
    }
    }
    @Test(priority = 2, enabled = true, description = "LogOut the Page")
    @Severity(SeverityLevel.NORMAL)
    @Description("To Verify the Logout Scenario : LogOut the tgWebApplication ")
    public void logOut() throws InterruptedException {
    @SuppressWarnings("deprecation")
    WebDriverWait wait = new WebDriverWait(driver, 7);
    wait.until(ExpectedConditions.elementToBeClickable(login.selectMenu())).click();
    System.out.println("->>> Select the Menu Bar Logout the Page Successfully

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

      Hi Pratheep, Its a bit difficult to study and troubleshoot code in youtube comments. Will need to look into your setup and logs.

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

    You only used string data in the excel, what about the numeric data. If we have combination of numeric columns and as well as string columns, how todo that?

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

      Hi Anil, pls check this - ruclips.net/video/B4G2tMDYjRQ/видео.html

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

    Where we used TestNg here ???..all the time we are using Main method. Is there any reason ???

    • @RaghavPal
      @RaghavPal  5 лет назад +1

      Hi Faisal, the main method is the starting point and for demo, using a sep class I used it. You can follow the steps and can implement it anywhere you need in your framework.

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

    sir, excel sheet me data alag position m ho to kaise likhenge loop m. maine bohot videos dekhe hai sab me same position me hi username passwword dikhaya hai. usko agar different position me rakh k koi video nahi mila

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

      Hi Ritesh, show me an example, how data is stored

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

      @@RaghavPal if we store data in 10 number row and 8 number column in any middle of cell . Then how we can adjust the loop

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

      I may not be able to understand exactly what you need here. Can get some help from here - ruclips.net/video/B4G2tMDYjRQ/видео.html

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

    Hello All,
    [Error] java.lang.ArrayIndexOutOfBoundsException could some one please help me...

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

      HI Mani, will need to see the logs and code where it is getting thrown from

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

      @@RaghavPal Thank you so much Raghav i fixed it by watching your videos. Am big Fan of you...

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

      @@RaghavPal
      Hi Raghav,
      I created data driven based on your video. where it contains one Data Provider and two test cases. I excel i have two column of data. When i execute the Test Case It runs 2 times of each method because it running based on the number of column, Could you please help me...

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

      I will need to look into the setup

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

      @@RaghavPal How can i share..Could you please tell me..

  • @AnilKumar-sf4em
    @AnilKumar-sf4em 2 года назад

    My requirement is, dataprovider having {1}{2} data and I have 2 methods in a class, I want to pass {1} to first method and {2} to second method,
    Is it possible, Plz provide the solution.
    public void Dataread{
    @DataProvider (name = "data"){
    public Object[][] dataMethod(){
    return new Object[][] {{"1"}, {"2"}};
    }

    @Test (dataProvider = "data")
    public void test1 (String val) {
    System.out.println("Test1 : " + val);
    }
    @Test (dataProvider = "data")
    public void test2 (String val) {
    System.out.println("Test2 : " + val);
    }
    }
    Expected output:
    Test1 : 1
    Test2 : 2

  • @Deniz-ss1sv
    @Deniz-ss1sv 3 года назад

    :)