Selenium Beginner Tutorial 11 - How To Create JAR File

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

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

  • @ammu1111
    @ammu1111 7 лет назад +10

    U make everything look simple and easy to learn ..thanks Raghav

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

    Hi raghav, it seems it would be very simple to learn selenium testing, but I would like to ask you to give a complete project automation testing example.

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

      Hi Abhi, i will do it soon.

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

    Thank you Raghav for all the useful videos. It is a real help for beginners like me.
    I created the executable jar file and getting error when running through command prompt.
    In the config file when I put Firefox, the test is running successfully
    when I put Chrome, it is giving "java.lang.IllegalStateException" driver executable doesnt exist error.
    Note: Both the browsers opening perfectly when I run from eclipse.

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

      Hi Dilsha, you will need to download and add chromedriver.exe

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

      chromedriver.exe is already installed and kept in lib\chromedrive folder. and add using the code
      if (browser.contains("Chrome"))
      {
      System.setProperty("webdriver.chrome.driver", "D:\\Dilu\\Java Projects\\SeleniumTest\\lib\\chromedriver\\chromedriver.exe");
      driver=new ChromeDriver();
      }
      Not sure why the code is running perfectly in eclipse(both Firefox and Chrome browsers are opening), and when it run through cmd prompt, it is showing error only for chrome browser (firefox opening without issues)

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

      Hi Dilsha, I believe in jar file chromedriver.exe is not getting added.

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

      ok.. I deleted the entire jar file, and recreated it. Now I am able to run it from the command prompt (Firefox & Chrome) opening without issue. Thanks for all your help :)

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

      Great to know this

  • @sym-john7795
    @sym-john7795 6 лет назад +2

    thanks for making this series .. its really awesome..Can you please add some videos on for input ,submit,select ..... and get return log, pass fail info, it will be more effective if you make a project for us.....

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

      Sure, i will soon plan to make complete project series on Selenium

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

    Hi sir, so once u had created a runnable jar, then it will create a jar on the present version of code right and then when you run the jar from the cmd, the getProperty() and setProperty() method get the value from the config,properties file of the jar right , here comes the question u had changed browser to firefox and ran the jar, why did the firefox browser open normally it should open the chrome browser right the method reads the value from jar's config,properties file right

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

      Hi Karanam, the config file will be read as per the path given in the code, and hence it is reading the config file that we altered. So this also means if you want to take this jar to another system, you should also take the config file along. It is also recommended to provide a relative path to config file in the code, so no changes are required on a new system/location

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

    You're very good at teaching.

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

      Thanks a lot for the compliment

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

    Really good content......I luv this channel

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

      Great to know this Lucky

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

    Nice and understandable video . How can we convert Cucumber BDD framwork to jar file and run from commandline

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

      Hi Rincy, you will have to package all the project with all dependencies in a runnable jar. I will not suggest this and a better option will be to create a maven project and you can also put it on cloud repo like GitHub, so you can pull and run it from any system.
      Can check this ruclips.net/p/PLhW3qG5bs-L8oRay6qeS70vJYZ3SBQnFa

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

    Hi Raghav, Thanks alot for sharing such an excellent video with us. I have an issue while I was running runnable jar file from other drive, its not able to find chrome driver as its not set in the path. So can you please advice me how should I overcome with such situation in the future? Best Regards, Dev

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

      Hi Darshan, so you can externalize all machine dependent variables. Like you can provide these from config files. I have a session in this series on config files. Moreover I would suggest to create a Mavenn project. You can find the videos here - automationstepbystep.com/909-2/online-courses/

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

    Hi Raghav, thank for this tutorial.
    I am facing an issue while creating jar file of my Selenium maven testng project.
    My project is running locally fine but after creating jar , it says unable to locale my property files or testng any resources.
    I am following following structure-
    Src/Main/java- where all Java code
    Src/main/resources- where all excel sheet , properties file config file aare stored.
    I am passing path by key value pair .
    Please help seriously stuck in this jar creations.

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

      Hi Diksha, do you get any logs. You can also skip this and move to next. This session is to provide knowledge on jar creation, but is not related to next one

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

      @@RaghavPal yes I do have logs . Actually i have created the complete framework but for creating runnable jar i am facing this issue. JAR is not able to read the classpath.

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

      Okay, may be we can see logs. But if you have moved to next one its fine

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

    Thanks for sharing
    I have a gradle Project and i want to create executable jar via command line. Can you help me how can i create.

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

      Hi Anoop, I had started a Gradle series, but yet to cover this scenario. For now pls try to get online help

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

    Hi Raghav, the test is not running in firefox from the command line, works fine with chrome.
    Exception in thread "main" java.lang.NullPointerException: Cannot invoke "org.openqa.selenium.WebDriver.get(String)" because "test.ModularProperpertyJar.driver" is null
    at test.ModularProperpertyJar.runTest(ModularProperpertyJar.java:63)
    at test.ModularProperpertyJar.main(ModularProperpertyJar.java:33)
    In eclipse both are working.
    Can you help me solve this?

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

      Hi Anshifa, not sure why its not working for Firefox. will need to check online.

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

    I have 1 question, what if i do not have a main method, because i am using TestNG annotations, which class would be my main method? thanks

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

      Hi Adrián, when you run as testng, we do not need a main method, it will run as per your code and setup and testng annotations

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

    Hi Raghav.....I am unable to select launch configuration while making a runnable jar file. how I will do this?

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

      Hi Pratheep, this can help stackoverflow.com/questions/3224364/launch-configuration-shows-up-blank-when-trying-to-export-runnable-jar/3224505

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

      @@RaghavPal I got it. it's working Raghav... Thanks a lot...

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

    Hi, i have this error no main manifest attribute. I've search for solution it says that i need to create something like manifest file? can you please explain it in comment and how to do it, thank you. And why i am experiencing it while i just follow all the steps that you did.

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

      Hi Michael, Pls check this
      stackoverflow.com/questions/9689793/cant-execute-jar-file-no-main-manifest-attribute
      www.edureka.co/community/7007/unable-to-execute-jar-file-no-main-manifest-attribute

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

    Hi raghav,by running test script in cmd line how we can make sure that test is passed or not?is there any way we can see result in html or some can file?

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

      Hi Ria, Mostly you can get some info or logs. You can also make use of tools like jenkins to publish report after execution

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

    Hi Raghav,
    Can we make jar file from command prompt or without making use of a IDE? Is it possible?

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

      Yes, we can Varsha, however I will suggest instead of creating a jar file, you can use a maven project. You can find a related videos in this playlist - ruclips.net/p/PLhW3qG5bs-L8oRay6qeS70vJYZ3SBQnFa

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

      @@RaghavPal Thank you

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

    Hi Raghav, When I am running my jar file through cmd it gave
    Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: C:\Workspace\lib\chromedriver\chromedriver.exe

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

      NOTE :- I did not save the jar in project itself ( When i saved it in the project itselt, Application is running)

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

      Glad to know this Pratishtha. Keep learning.

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

    how can we create a jar for the Framework build using pageobjectmodel Factory since I don't have any mail class

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

      Hi Sandeep, JARs are good for small individual and stand alone modules. You should consider creating a maven project. Can see this - ruclips.net/p/PLhW3qG5bs-L8oRay6qeS70vJYZ3SBQnFa

  • @knownothing1277
    @knownothing1277 7 лет назад

    On my eclipse I am having bit problem with set-up runable jar as it is not showing all the lists of the name in Launch configuration box and also can't type the file destination (C://users/......) in the Export destination box. Could you please explain it where I am wrong? Thanks.

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

      Alok have you compiled your project before taking the jar. In case you are having major issues with your eclipse try getting a new eclipse. Watch this - Java Beginner Tutorial 4 - Getting Started with Eclipse IDE - ruclips.net/video/rpB1WWqZ6HQ/видео.html

    • @mridiot9564
      @mridiot9564 7 лет назад

      Hi Roy, before creation of jar, you have to select the Main method containing class under RunConfiguration with wanted Name, then only you can see that given name under Launch configuration.

  • @subodhtalks-stocks
    @subodhtalks-stocks 7 лет назад

    i created a jar file of a TestNG project and now when i am running the program from cmd it gives me " Could not find or load main class "xyz".jar" any idea why this error getting displayed. if possible provide me a link where i can get the resolution

    • @mridiot9564
      @mridiot9564 7 лет назад

      You have to create a new class file with main method, and within that write steps for calling TestNG XML, and then you have to create JAR file by selecting new class as an entry point.

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

    Hi Ragav I have created jar file but when I run this jar it only create output folder but not running the script

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

      Hi Rehan, will need more details and logs to troubleshoot. However I will suggest instead of jar, you can go with creating a maven project, Can find videos here - ruclips.net/p/PLhW3qG5bs-L8oRay6qeS70vJYZ3SBQnFa

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

    How can I run the jar file without placing the jar file inside project location as I can see it wraps the entire project into jar file. Path location of properties file, data file uses relative path using System.getProperty("user.dir"); so when i place the jar file in desktop and run via command prompt it takes the desktop path followed by the relative path of the file. How can I access the file path which is inside jar file.

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

      Hi Ram, I will need to check and confirm with a hands-on

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

    Hi I want to know if could be possible to include the properties file inside the runnable jar????

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

      Hi Walter, I believe properties file should be kept outside the jar so it is modifiable, that's the use of it. Check here - stackoverflow.com/questions/1507118/create-runnable-jar-with-properties-files-using-java-eclipse

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

      @@RaghavPal Thanks Raghav.

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

    Is it possible to create testng report .....from java executable jar file ...thank u .

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

      Hi, although if you configure everything in jar file, you can do it, but will not be recommended. I will suggest you create a maven project for your framework. Can follow this - ruclips.net/p/PLhW3qG5bs-L8oRay6qeS70vJYZ3SBQnFa

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

    Thank u sir

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

    suppose i'm using testng which has no main method, will it work then?

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

      Hi Saurav, if you are using testng, I will suggest not to use this way, there are other ways to run from testng, and also commandline options are available in testng.

  • @jyothimulakala3286
    @jyothimulakala3286 7 лет назад

    hii can u tell me how to create a jarfile for seleniumframework for specific method how to impliment that can u tell me detail

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

      will do a session on that. You can also watch - ruclips.net/video/QB19Wqimkq4/видео.html

  • @jyothimulakala3286
    @jyothimulakala3286 7 лет назад

    after creating a jar file iam not getting src,config file can u tell me in detailed way how to get that configured file

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

      Jyothi, the src folder is present already in the framework as created in earlier sessions. In the video because i saved the jar file in the same location so you are seeing src folder. You can do the same save it in your project path.

    • @mridiot9564
      @mridiot9564 7 лет назад

      hi Jyothi, JAR file fails to read config and properties file. Keeping the config file in the project root location with code changes and then create JAR file, whenever you are using this jar file outside the project folder or different system make sure you are shifting the jar along with config file. Or else jar file fails to find the config file.

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

    How to run only specific tests not all tests using jar file?

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

      Hi Harinat, for that you will need to use some Test Runner or tools like TestNG. I have not yet covered that. Will be doing soon.

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

    Hi Raghav, I'm getting the following error whenever I try to execute the JAR file from the command line. Appreciate your inputs
    java -jar SeleniumTest.jar
    Firefox
    Firefox
    Exception in thread "main" org.openqa.selenium.WebDriverException: Build info: version: '4.0.0-alpha-5', revision: 'b3a0d621cc'
    System info: host: 'Ushas-MacBook-Air.local', ip: 'fe80:0:0:0:81d:513:f4be:916a%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '14.0.1'
    Driver info: driver.version: FirefoxDriver
    at java.base/java.util.Optional.orElseThrow(Optional.java:401)
    at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:184)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:156)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:134)
    at test.FirstSeleniumTest.setBrowserConfig(FirstSeleniumTest.java:29)
    at test.FirstSeleniumTest.main(FirstSeleniumTest.java:18)

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

      Hi Usha, the logs are not complete. Pls check you should find a Caused by section in the logs

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

      Hi Raghav, thanks for your response. Could you please walk me through how to find the 'Caused by' section. Currently i can only see the below errors in my terminal.
      seleniumProject usha2004$ java -jar SeleniumTest.jar
      Firefox
      Firefox
      Exception in thread "main" org.openqa.selenium.WebDriverException: Build info: version: '4.0.0-alpha-5', revision: 'b3a0d621cc'
      System info: host: 'Ushas-MacBook-Air.local', ip: 'fe80:0:0:0:81d:513:f4be:916a%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '14.0.1'
      Driver info: driver.version: FirefoxDriver
      at java.base/java.util.Optional.orElseThrow(Optional.java:401)
      at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:184)
      at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:156)
      at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:134)
      at test.FirstSeleniumTest.setBrowserConfig(FirstSeleniumTest.java:29)
      at test.FirstSeleniumTest.main(FirstSeleniumTest.java:18)
      ----------------
      seleniumProject usha2004$ java -jar SeleniumTest.jar
      Chrome
      Chrome
      Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from chromedriver.storage.googleapis.com/index.html
      at com.google.common.base.Preconditions.checkState(Preconditions.java:843)
      at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:142)
      at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:36)
      at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:195)
      at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:389)
      at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:118)
      at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:105)
      at test.FirstSeleniumTest.setBrowserConfig(FirstSeleniumTest.java:32)
      at test.FirstSeleniumTest.main(FirstSeleniumTest.java:18)

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

      I'm able to run the file on eclipse though, only with the JAR I have issues. Secondly, i set the system property using 'Run Configurations' in eclipse instead of setting it in the code like you had mentioned in your lesson. Can this cause the above error?

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

      Okay for chrome looks like the issue is with driver path. You can try saving the browser drivers in a folder within the project and provide relative path in script. If you still face issues, you can skip and move to next video for now

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

    ""Error: Unable to access jarfile Test.jar"" i m facing this error ,please give me a suggestion to fix this brother

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

      Hi Harish, will need more details. Where exactly you got this error. Do you have any logs?

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

      @@RaghavPal
      Thanks a lot for the response Raghav, I follow ur video's from last year, I learned many automation techniques and implemented in my project too.
      Here I drop the logs of the error
      ""C:\Users\harish.LIQUID-UI0>cd D:\jar
      C:\Users\harish.LIQUID-UI0>java -jar Test.jar
      Error: Unable to access jarfile Test.jar ""
      (Request)-------> Now a days everyone uses Maven project compare to java project, Please make a video for" Jar file creation in Maven Project".

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

      Is the jar file available in the location where your cmd is.
      Yes maven is what you should be doing
      Check here - ruclips.net/p/PLhW3qG5bs-L8oRay6qeS70vJYZ3SBQnFa

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

    When I run code in other system it show fail,But in my system it’s working

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

      Hi Sanu, will do so, Let me know the error message you are getting

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

      It show failure in other system but in my system it show successful.can you provide any this kind ofvideo

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

      I will need to see some logs for this