Sunday, July 14, 2019

How to control Chromedriver using curl

How to control Chromedriver using curl

Here is how to use Chromedriver without libraries like selenium-webdriver. This can be useful for debugging.
The following example visits a web page and reads the a headline's text contents.


1. download chromedriver.exe on windows/mac, go to the same directory and run this command:

On Mac: ./chromedriver &
On Windows: chromedriver.exe

2. Create a session:
Java Code:
WebDriver driver = new ChromeDriver();

Curl Command:
curl -XPOST http://localhost:9515/session -d '{"desiredCapabilities":{"browserName":"chrome"}}'

3. launch a URL:
Java Code:
driver.get("https://www.google.com");

Curl Command:
curl http://localhost:9515/session/142a7f9bb57b8fda48636c8709df9591/url -d '{"url":"https://www.google.com"}'

4. find an element:
Java Code:
WebElement element = driver.findElement(By.name("q"));

Curl Command:
curl http://localhost:9515/session/142a7f9bb57b8fda48636c8709df9591/element -d '{"using":"name", "value":"q"}'


5. enter text in element:
Java Code:
element.sendKeys("Naveen AutomationLabs");

Curl Command:
curl http://localhost:9515/session/142a7f9bb57b8fda48636c8709df9591/element/0.45843488917986774-1/value -d '{"value":["Naveen Automation Labs"]}'

6. Quit Browser/close the session:
Java Code:
driver.quit();

Curl Command:
curl -X DELETE http://localhost:9515/session/142a7f9bb57b8fda48636c8709df9591


Chromedriver follows the W3C WebDriver spec. There are tons of things you can do with it, but tasks that are simple using something like selenium-webdriver can be quite difficult.
However, for simple debugging or remote-controlling, consider just using curl.


Cheers!!
Naveen AutomationLabs



Tuesday, July 9, 2019

Usage of Cucumber Options which we use in TestRunner File


Usage of Cucumber Options which we use in TestRunner File

TestRunner File is used to build a Communication between Feature Files and StepDefinition Files. 


features: We use Cucumber features option to define path of feature file(s). 

glue: We use Cucumber glue option to define path of step definition file(s). 

format: We use Cucumber format option to generate output or test results in different types of formats. 
Eg: HTML Report, JUnit or TestNG Report, Cucumber Report and So. 

monochrome: We use Cucumber monochrome option to print console output in a very readable format. 
monochrome must be set to true in order to achieve it. 

strict: We use Cucumber strict option to check if any step if not defined in step definition file. 
If any step is not defined in step definition file then it will stop an execution of program. 

dryRun: We use Cucumber dryRun option to check whether all the steps from feature files has got methods and implemented or no in Step Definition File. 
Before execution of program dryRun must be set to true and we need to make sure that all steps are implemented in Step Definition File. 
Once we are sure that all steps are implemented then dryRun must be set to False and we should continue with Test Execution.

tags: We use Cucumber tags option when we have more number of scenarios in a single feature file which represents different purpose [Smoke, Sanity, Regression etc] in such cases we can make use tags option.
Eg: tags={ " @ Smoke " } >> It will pick only and only those scenarios which are tagged with Smoke in feature files.

   This blog is contributed by Pavan KrishnanReddy Working as Testing Executive at Infosys Limited            










Cheers!
Naveen AutomationLabs

Monday, July 8, 2019

How to solve Maven issue - Could not resolve archetype org.apache.maven.archetypes from any of the configured repositories.

How to solve Maven issue - Could not resolve archetype org.apache.maven.archetypes from any of the configured repositories.


  • Problem: - 


Solution
Steps to follow:
  1. Right click on project
  2. click on properties
  3. java build path
  4. select source
  5. add, apply then OK



6. Open window preferences
7. open Maven
8. deselect all dialog box



9. Open window : preferences, open Maven Archetype, click on ‘Add Remote catalog’ and add Catalog file: http://repo1.maven.org/maven2/archetype-catalog.xml
Description: Maven Catalog.



10. check library, right click on project
click on properties, go to java build path
click libraries
add external jars
add, apply ok. 

Error Resolved!! YEY!


This is Nazia. I have recently completed my post-graduation. Later I
joined Naveen Automation Labs which is one of the best online training
programs and improved my automation skills a lot. I face some difficulties
while configuring Maven, so I tried some of the possible ways to solve
them, hope this will help you as well.




Cheers!
Nazia
-Naveen AutomationLabs

Featured Post

Advanced Selenium Webdriver Interview Questions and Answers in Java

Advanced Selenium Webdriver Interview Questions and Answers in Java Selenium WebDriver - QA Here is the list of Selenium Inte...