Forward and Backward Navigation

Click here to get Java Snippet for this script.

__author__ = 'Gaurav.Khanna'

from selenium import webdriver

# Initializing FireFox Driver
webDriver = webdriver.Firefox()

# Assigning URL to variable 'baseUrl'
baseUrl = "http://book.theautomatedtester.co.uk"

# Open the link
webDriver.get("http://book.theautomatedtester.co.uk")

# Maximize browser window
webDriver.maximize_window()

# Click on link
webDriver.find_element_by_link_text("Chapter1").click()

# Print Page Title
print(" Page Title : " + webDriver.title)

# Using Back Method
webDriver.back()

# Print Page Title
print(" Page Title : " + webDriver.title)

# Using Forward Method
webDriver.forward()

# Print Page Title
print(" Page Title : " + webDriver.title)

# This will close the browser
webDriver.quit()

File Uploading

Click here to get Java Snippet for this script.

__author__ = 'Gaurav Khanna'

from selenium import  webdriver 

# Initializing FireFox Driver
webDriver = webdriver.Firefox()

# Assigning URL to variable 'baseUrl'
baseUrl = "http://www.htmlcodetutorial.com/forms/_INPUT_TYPE_FILE.html"

# Open the link
webDriver.get(baseUrl)

# Maximize browser window
webDriver.maximize_window()

# Upload File
webDriver.find_element_by_name("upfile").send_keys("C:\\gaurav\\gaurav.txt")

# Click on Submit Button
webDriver.find_element_by_xpath("//input[@value='Submit']").click()

#This will close the browser
webDriver.quit()

Extracting Links from Web Page

Click here to get Java Snippet for this script.

__author__ = 'Gaurav.Khanna'

from selenium import webdriver

# Initializing FireFox Driver
webDriver = webdriver.Firefox()

# Open URL
webDriver.get("http://not-just-a-tester.blogspot.in/")

# Find all anchor tags
allLinks = webDriver.find_elements_by_tag_name("a")

# Print All Links
for links in allLinks:
    print(links.get_attribute('href'))
    print("\n")

# Close Browser
webDriver.close()

Basic Script 2

Click here to get Java Snippet for this script.

__author__ = 'Gaurav.Khanna'

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import select

# Initializing FireFox Driver
webDriver = webdriver.Firefox()

# Assigning URL to variable 'baseUrl'
baseUrl = "http://www.webmath.com/"

# Wait for 30 seconds using Implicit Wait
WebDriverWait(webDriver,30)

# Open the link
webDriver.get(baseUrl)

# Click on element
webDriver.find_element_by_id("www-content-wrap").click()

# Select `Simple Interest` option from drop down
select.Select(webDriver.find_element_by_id("topicItem")).select_by_visible_text("Interest, Simple")

# Click on element
webDriver.find_element_by_css_selector("option[value=\"simpinterest.html\"]").click()

# Clear Field
webDriver.find_element_by_name("principal").clear()

# Enter value
webDriver.find_element_by_name("principal").sendKeys("1000")

# Clear Field
webDriver.find_element_by_name("interest").clear()

# Enter value
webDriver.find_element_by_name("interest").send_keys("1")

# Clear Field
webDriver.find_element_by_name("desired_time").clear()

# Enter value
webDriver.find_element_by_name("desired_time").send_keys("5")

# Click on element
webDriver.find_element_by_name("//input[@value='Find the amount of interest']").click()

# Close Browser
webDriver.close()

Get Attribute Method

Click here to get Java Snippet for this script.

__author__ = 'Gaurav.Khanna'

from selenium import webdriver

# Initializing FireFox Driver
webDriver = webdriver.Firefox()

# Assigning URL to variable 'baseUrl'
baseUrl = "http://book.theautomatedtester.co.uk/chapter1"

# Open the link
webDriver.get(baseUrl)

# Locate Button and Store the value of button to 'attributeValue' variable
attributeValue = webDriver.find_element_by_id("verifybutton").get_attribute("value")

# Printing value of 'attributeValue'
print("Attribute Value : " + attributeValue)

# This will close the browser
webDriver.quit()

Expectations from Automation Testing

Hi All,

This article about the expectations of Individuals/Teams/Company from Automation department. Expectations, of course, are to automate all regression test cases which are panic or monotonus for Manual team. But there are more than this which I will be explaining as per the things I have observed :

1. 100% Automation : This is the most common expectation and desire that every team has. But, it is really difficult to achieve considering various factors i.e. frequent requirements change, pending test cases updation, test data missing, etc. 100% Automation can be done for bunch of Test Cases out of Complete Test Suites. If we have 1000 of TCs and we want to cover all of them. Then, it require huge amount of amount and will results in wastage in future considering the above factors.

2. Finding New Defects : Is this possible? Of course, No. Automation is running regression TCs to reduce the repetative acitivity on new build. It will help to find regression defects. But any new type of defect is not possible.

Manual Testing Interview Questions

What is bug leakage and bug release?

Bug release is when software or an application is handed over to the testing team knowing that the defect is present in a release.  During this the priority and severity of bug is low, as bug can be removed before the final handover.

Bug leakage is something, when the bug is discovered by the end users or customer, and missed by the testing team to detect, while testing the software.