FirefoxIDEforSelenium是否使用selenium库导出到常规python代码?
python selenium库页面包含以下示例:FirefoxIDEforSelenium是否使用selenium库导出到常规python代码?,python,selenium,Python,Selenium,python selenium库页面包含以下示例: from selenium import webdriver from selenium.common.exceptions import NoSuchElementException from selenium.common.keys import Keys from time browser = webdriver.Firefox() # Get local session of firefox browser.get("http://w
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.common.keys import Keys
from time
browser = webdriver.Firefox() # Get local session of firefox
browser.get("http://www.yahoo.com") # Load page
assert browser.title == "Yahoo!"
elem = browser.find_element_by_name("p") # Find the query box
elem.send_keys("selenium" + Keys.RETURN)
time.sleep(0.2) # Let the page load, will be added to the API
try:
browser.find_element_by_xpath("//a[contains(@href,'http://seleniumhq.org')]")
except NoSuchElementException:
assert 0, "can't find seleniumhq"
browser.close()
但当我从firefox selenium IDE导出保存的会话时,python代码看起来大不相同:
from selenium import selenium
import unittest, time, re
class create_order(unittest.TestCase):
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", 4444, "*chrome", "http://localhost/")
self.selenium.start()
def test_create_order(self):
sel = self.selenium
sel.open("/User/LogOn")
sel.type("UserName", "testuser")
sel.type("Password", "123")
sel.click("//input[@value='login']")
sel.wait_for_page_to_load("30000")
sel.click("link=Settings")
sel.wait_for_page_to_load("30000")
sel.click("//input[@value='Some Link']")
sel.wait_for_page_to_load("30000")
sel.click("link=Save>")
sel.wait_for_page_to_load("30000")
def tearDown(self):
self.selenium.stop()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
它使用了不同的API吗?第一个代码段使用了更新的WebDriver API 第二个代码段使用原始的Selenium1API
第一个代码段使用了更新的WebDriver API 第二个代码段使用原始的Selenium1API
其他python代码是什么?IDE吐出的代码,更新了上面的问题。其他python代码是什么?IDE吐出的代码,更新了上面的问题。