Skip to content

Instantly share code, notes, and snippets.

@easonhan007
Created June 23, 2014 10:58
Show Gist options
  • Save easonhan007/188ed2c856b64e1341cd to your computer and use it in GitHub Desktop.
Save easonhan007/188ed2c856b64e1341cd to your computer and use it in GitHub Desktop.
python selenium中使用jquery
# -*- coding: utf-8 -*-
from selenium import webdriver
import time
import unittest
dr = webdriver.Chrome()
dr.get("http://192.168.10.21:28080/admin/tag/list.do")
jqueryPath = 'D:/jquery-1.7.1.js'
jqueryFile = open(jqueryPath)
jquery = jqueryFile.read()
jqueryFile.close()
js = '''$(".table_td:contains('APP Tag 1403513107.4')")[0].parentElement.children[2].children[0].click();'''
dr.execute_script(jquery+js)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment