찾다

 >  Q&A  >  본문

python - selenium server 我这样写 跟用selenium ide录的这个有什么区别吗?

from selenium.webdriver import Remote
import time
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
driver = Remote(command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities={'platform': 'ANY',
                      'browserName':'firefox',
                      'version': '',
                      'javascriptEnabled': True})
driver.get('http://www.baidu.com')
title=driver.title
print (title)
time.sleep(3)
driver.quit()

上面是我写的

下面是用selenium ide录的

from selenium import selenium
import unittest, time, re

class rc(unittest.TestCase):
    def setUp(self):
        self.verificationErrors = []
        self.selenium = selenium("localhost", 4444, "*chrome", "https://www.baidu.com/")
        self.selenium.start()

    def test_rc(self):
        sel = self.selenium
        sel.open("/")
        sel.type("id=kw", "selenium")
        sel.click("id=container")
        sel.click("id=su")

    def tearDown(self):
        self.selenium.stop()
        self.assertEqual([], self.verificationErrors)

if __name__ == "__main__":
    unittest.main()

都是用selenium server
这两段代码有什么区别?
指的是,它们都可以用selenium server吧?

呃。。。好像没说明白,能理解吗!

迷茫迷茫2794일 전542

모든 응답(0)나는 대답할 것이다

답장 없음
  • 취소회신하다