Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
FirefoxIDEforSelenium是否使用selenium库导出到常规python代码?_Python_Selenium - Fatal编程技术网

FirefoxIDEforSelenium是否使用selenium库导出到常规python代码?

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

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://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吐出的代码,更新了上面的问题。