@沈佳龙
显然Python的效率更高啊~
#simple Example For Selenium By Python
#_*_ coding:UTF-8 _*_
__author__ = 'archer
from selenium import webdriver
from selenium.common.exceptions import *
import time
class SomeTest(object):
def __init__(self):
pass
def myfirsttest(self,myurl):
'start url'
browser=webdriver.Firefox()
browser.get(myurl)
'Start to Find a element'
try:
myemail=browser.find_element_by_id('email')
mypass=browser.find_element_by_id('password')
myloginbutton=browser.find_element_by_class_name('login-submit')
except NoSuchElementException:
assert 0,'找不到元素'
else:
myemail.send_keys('gongtianyu@kedacom.com')
mypass.send_keys('**********')
myloginbutton.click()
time.sleep(2)
if __name__=='__main__':
mytest=SomeTest()
mytest.myfirsttest('http://weibo.kedacom.com')