使用python+ selenium 编写简单的自动化脚本的时候,自己写出简单的代码如下:
import unittest
from selenium import webdriver
import time
class LoginCase(unittest.TestCase):
def setUp(self):
print('before test')
self.dr = webdriver.Chrome()
self.dr.get('http://localhost:81/wp-login.php')
def write(self):
user_name = 'admin'
pass_word = '123456'
self.t_login(user_name, pass_word)
title = 'this is title %s' % (time.time())
self.dr.get('http://localhost:81/wp-admin/post-new.php')
self.by_name('post_title').send_keys(title)
self.set_content('content,content')
self.by_name('publish').click()
self.dr.get('http://localhost:81/wp-admin/edit.php')
self.assertEqual(self.by_css('.row-title').text, title)
def set_content(self, text):
js = "document.get