Take Screenshot with Selenium Webdriver

You can take screenshot of browser with browser. Python: you can use get_screenshot_as_file(path_to_save). # -*- coding: UTF-8 -*- import unittest from selenium import webdriver class TestClass(unittest.TestCase):     def setUp(self):         self.driver = webdriver.Firefox()          def test_MahsumAkbasNet_Pass(self):                  self.driver.get(“http://www.mahsumakbas.net/selenium”)                  self.driver.save_screenshot(“D:\\python_selenium_screenshot.jpg”)              def tearDown(self):         self.driver.quit() if __name__… Read More »

Run Selenium Scripts with Jenkins CI

You write your automation script, they are working perfectly anf got perfect result. But, will you run script everytime manually? Solution is Continuous Integration tools. Most known is Jenkins. Let’s setup a job to run our test. Open Jenkins homepage Click on New Item link at left-top corner Because of we have a simple python… Read More »

Selenium Webdriver – Run Javascript in Python

Selenium Webdriver provide a way to run(call) Javascript code in your test. There is a Javascript execution function for each language. For Python, this function is execute_script(code). you can see a basic usage of this function at below. After run it, you can see alert pop up with. also, you can see that appeared pop… Read More »

Selenium Webdrvier – Wait jQuery Ajax Request Complete in Python

if you have a jQuery Ajax request in your test web page, you should wait to request to complete. Otherwise, unexpected behaviours can occur. in Selenium Webdriver, we can perform by Javascript running function: execute_script() jQuery provide a parameter to check request status. “active” is one of jQuery library. if value is 1 it means… Read More »

Selenium – Expected Conditions functions in Python

in past, i posted for usage of Expected Conditions function. it that post, present the most frequently used function visibility_of_element_located(locator). Similarly, there are many function for expected conditions. These are: alert_is_present element_located_selection_state_to_be element_located_to_be_selected element_selection_state_to_be element_to_be_clickable – it is Displayed and Enabled. element_to_be_selected frame_to_be_available_and_switch_to_it invisibility_of_element_located presence_of_all_elements_located presence_of_element_located staleness_of text_to_be_present_in_element text_to_be_present_in_element_value title_contains title_is visibility_of visibility_of_element_located you can find detailed… Read More »

Selenium – Multiple Test in Python Class

A Python Unittest Class consist of 3 basic functions. def setUp(self): => it is first function running before test cases. generally, define Class-wide objects/variables such as drvier, timeout settings etc.. def test_xxx(self): => it is test case function that to be running. test case functions in unittest shoud start with “test_” def tearDown(self): => it is running… Read More »

Selenium – Assertion with Python Unittest

in a previous post, i shared a basic script to use Python Unittest. At that post, there is not any Assertion(verification). Now, let’s see power of Assertions. after we prepare our test and its steps, we will need at some point to check results. in following example, get header title and compare it if it correct… Read More »

Selenium – Wait For Element – Python

In Test Automation progress, one og the most important point is check element existence status. Sometimes you need to wait for any element to be appear or disappear. Selenium has wait and Expected Conditions functions. following examples is a simple action that wait for a <div> element with ID of “ajaxReturnDiv”. # -*- coding: UTF-8… Read More »