Testing :
- It involves identifying bug/error/defect in a software without correcting it.
- Testing is the process of evaluating a system or its component(s) with the intent to find whether it satisfies the specified requirements or not.
Debugging :
- It involves identifying and fixing the problems/bugs.
Who does Testing?
- In the IT industry, large companies have a team with responsibilities to evaluate the developed software in context of the given requirements.
different types of testing:
- Manual Testing
- Automation Testing
Manual Testing:
- Manual
testing includes testing a software manually, i.e., without using any automated
tool or any script.
Automation Testing:
- Automation
testing, which is also known as Test Automation, is when the tester writes
scripts and uses another software to test the product.
- Selenium
- QTP
- Jmeter
- Loadrunner
- TestLink
- Quality Center(ALM)
Selenium
It
is a software testing tool used for regression testing. It is an open source
testing tool that provides playback and recording facility for regression
testing. The Selenium IDE only supports Mozilla Firebox web browser.
- It
provides the provision to export recorded script in other languages like Python,Java, Ruby, C#.
- It can execute multiple tests at a time
- Autocomplete for Selenium commands that
are common Walk through tests
- Identifies the element using id, name ,
X-path, etc.
- Store tests as Python Script,Ruby Script, HTML, and
any other format.
- It provides an option to assert the
title for every page
- It supports selenium user-extensions file
- It
allows to insert comments in the middle of the script for better understanding
and debugging
In-order to work with selenium with python program first we install selenium.
pip install selenium
we are testing web-applications through web browsers, we need some web-browser related drivers.download that drivers and install that drivers.
download and install geckodriver for Chrome or Firefox or IE.
What is Gecko and GeckoDriver?
- Gecko is a web browser engine used in many applications developed by Mozilla Foundation and the Mozilla Corporation.
- Gecko Driver is the link between your tests in Selenium and the Firefox browser.
- GeckoDriver is a proxy for using W3C WebDriver-compatible clients to interact with Gecko-based browsers i.e. Mozilla Firefox
example1:
from selenium import webdriver
browser=webdriver.Chrome()
browser.get('https://www.facebook.com')
example2:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
browser=webdriver.Chrome()
browser.get('https://www.facebook.com')
element=browser.find_element_by_name('email')
element.send_keys('divyakola43@gmail.com'+Keys.RETURN)
element1=browser.find_element_by_name('pass')
element1.send_keys('sivakrishna143'+Keys.RETURN)
example3:
import time
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
driver.get('http://google.com')
element = driver.find_element_by_link_text('About')
ActionChains(driver) \
.key_down(Keys.CONTROL) \
.click(element) \
.key_up(Keys.CONTROL) \
.perform()
time.sleep(30) # Pause to allow you to inspect the browser.
driver.quit()
example4:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
browser = webdriver.Chrome()
browser.get('http://www.yahoo.com')
elem = browser.find_element_by_name('p') # Find the search box
elem.send_keys('seleniumhq' + Keys.RETURN)
browser.quit()
example5:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()
example6: unittest
import unittest2 as unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
class PythonOrgSearch(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
def test_search_in_python_org(self):
driver = self.driver
driver.get("http://www.python.org")
self.assertIn("Python", driver.title)
elem = driver.find_element_by_name("q")
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
def tearDown(self):
self.driver.close()
from selenium import webdriver
browser=webdriver.Chrome()
browser.get('https://www.facebook.com')
example2:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
browser=webdriver.Chrome()
browser.get('https://www.facebook.com')
element=browser.find_element_by_name('email')
element.send_keys('divyakola43@gmail.com'+Keys.RETURN)
element1=browser.find_element_by_name('pass')
element1.send_keys('sivakrishna143'+Keys.RETURN)
example3:
import time
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
driver.get('http://google.com')
element = driver.find_element_by_link_text('About')
ActionChains(driver) \
.key_down(Keys.CONTROL) \
.click(element) \
.key_up(Keys.CONTROL) \
.perform()
time.sleep(30) # Pause to allow you to inspect the browser.
driver.quit()
example4:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
browser = webdriver.Chrome()
browser.get('http://www.yahoo.com')
elem = browser.find_element_by_name('p') # Find the search box
elem.send_keys('seleniumhq' + Keys.RETURN)
browser.quit()
example5:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()
example6: unittest
import unittest2 as unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
class PythonOrgSearch(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
def test_search_in_python_org(self):
driver = self.driver
driver.get("http://www.python.org")
self.assertIn("Python", driver.title)
elem = driver.find_element_by_name("q")
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
def tearDown(self):
self.driver.close()
No comments:
Post a Comment