Selenium Two Tutorial using IronPython and InternetExplorerDriver - The Automated Tester
2012-12-13 17:52
639 查看
Selenium Two Tutorial using IronPython and InternetExplorerDriver - The Automated Tester
This tutorial is to show how to use the .NET Selenium 2 with dynamic languages that run on the .NET Common Language Runtime. This tutorial uses IronPython.
To complete this tutorial you will need to have IronPython installed and you will also need to download the .NET Bindings from Google Code
This tutorial will not be using the Remote Driver and it will be using the InternetExplorerDriver as this is the only complete browser at the moment that doesn't need to be built from the Repository.
Lets start by creating a directory that will hold the IronPython script. Lets call it SeleniumTwoExamplePython
Copy the WebDriver.Common.dll, WebDriver.IE.dll and InternetExplorerDriver.dll files into the newly created directory in the step above. Make sure the version of InternetExplorerDriver.dll matches the architecture of your operating system.
We are now ready to have our write our first test!Copy the code below into a Python IDE or Notepad. Save the file as testgoogle.py
Now you have a test that launch a browser and do a search on Google for you. In a command prompt run ipy testgoogle.py
Now you have created your first test that uses WebDriver.
Selenium Two Tutorial using IronPython and InternetExplorerDriver
Mon 11 Jan 2010This tutorial is to show how to use the .NET Selenium 2 with dynamic languages that run on the .NET Common Language Runtime. This tutorial uses IronPython.
To complete this tutorial you will need to have IronPython installed and you will also need to download the .NET Bindings from Google Code
This tutorial will not be using the Remote Driver and it will be using the InternetExplorerDriver as this is the only complete browser at the moment that doesn't need to be built from the Repository.
Lets start by creating a directory that will hold the IronPython script. Lets call it SeleniumTwoExamplePython
Copy the WebDriver.Common.dll, WebDriver.IE.dll and InternetExplorerDriver.dll files into the newly created directory in the step above. Make sure the version of InternetExplorerDriver.dll matches the architecture of your operating system.
We are now ready to have our write our first test!Copy the code below into a Python IDE or Notepad. Save the file as testgoogle.py
import sys import unittest try: import clr clr.AddReference("WebDriver.Common.dll") clr.AddReference("WebDriver.IE.dll") from OpenQA.Selenium import * from OpenQA.Selenium.IE import * except ImportError: sys.exit("This needs to be run in IronPython") class TestGoogle(unittest.TestCase): def setUp(self): ''' Start the driver ''' self.driver = InternetExplorerDriver() def testGoogleSearchForTheAutomatedTester(self): ''' Test to have a load Google and the search for The Automated Tester ''' #Navigate to the site self.driver.Navigate().GoToUrl("http://www.google.com/") #Create an object for an element on the page queryBox = self.driver.FindElement(By.Name("q")) queryBox.SendKeys("The Automated Tester") #Submit the form queryBox.Submit() #Check the title of the new page has The Automated Tester in the Title self.assertTrue("The Automated Tester" in self.driver.Title) def tearDown(self): ''' Clean up the driver ''' self.driver.Quit() if __name__ == '__main__': unittest.main()
Now you have a test that launch a browser and do a search on Google for you. In a command prompt run ipy testgoogle.py
Now you have created your first test that uses WebDriver.
相关文章推荐
- A problem displaying [localhost] caused Internet Explorer to refresh the webpage using Compatibility
- [Selenium] 如何使 InternetExplorerDriver 每次启动的端口不会随机变化
- The Python Tutorial - Input and Output
- Python Selenium 调用浏览器失败Unexpected error launching Internet Explorer解决方法
- Selenium - The architecture differences between Selenium RC and Selenium WebDriver
- How can selenium web driver get to know when the new window has opened and then resume its execution
- Python use Selenium to control the webdriver
- Drawing lines in Mozilla based browsers and the Internet Explorer
- Python - Headless Selenium WebDriver Tests using PyVirtualDisplay
- Using IBM Rational Functional Tester: Understanding and Using the TestObject.find Method
- (转)Using the right version of MSXML in Internet Explorer
- PAMIE的全称是Python Automated Module For Internet Explorer,顾名思义,PAMIE是一个实现IE自动化的模块
- python网络编程经典好文,如何用urllib获取internet资源,HOWTO Fetch Internet Resources Using The urllib Package
- Python Web-第六周-JSON and the REST Architecture(Using Python to Access Web Data)
- Lootcode 1. Two Sum The Solution of Python and Javas
- [Selenium] 配置 Internet Explorer Driver 的注意事项
- webdriver 实例 IE8报错:Unexpected error launching Internet Explorer. Protected Mode settings are not the
- using JS to control two select(html),the data can be loaded from database and XML,and show in the select
- Python Programming with the Java(TM) Class Libraries: A Tutorial for Building Web and Enterprise App
- Along with all the above benefits, you cannot overlook the space efficiency and performance gains in using DataFrames and Dataset APIs for two reasons.