selenium+python自動化96-執行jquery報:$ is not defined
遇到問題
1.在執行jquery腳本的時候,報錯:
selenium.common.exceptions.WebDriverException: Message: unknown error: $ is not defined
2.後來嘗試了以下幾種方法都無果:
sleep時間加長一點,讓頁面加載完成
換一種click方法:
$(‘.btn‘).trigger(‘click‘)
$(‘.btn‘).eq(0).trigger(‘click‘)
js解決
1.後來跟懂jquery的大神溝通了下,由於我訪問的是一個wap頁
2.目前很多H5的頁面,前端開發的框架如果使用的是vue,用$就不行,所以此方法行不通,後來用js就解決了
# 執行js
js = 'document.getElementsByClassName("btn")[0].click();'
driver.execute_script(js)
selenium+python自動化96-執行jquery報:$ is not defined
相關推薦
selenium+python自動化96-執行jquery報:$ is not defined
code exception ssa 完成 python defined get png 溝通 遇到問題 1.在執行jquery腳本的時候,報錯: selenium.common.exceptions.WebDriverException: Message: unknow
Python reload(sys) NameError: name 'reload' is not defined
對於 Python 2.X: import sys reload(sys) sys.setdefaultencoding("utf-8") 對於 <= Python 3.3: import im
python+selenium對網頁執行js指令碼報錯“$ is not defined”
背景 在python裡用selenium模擬瀏覽器的時候需要傳送一個POST請求,我用的是webdriver的execute_script方法,對頁面執行下面的js程式碼來獲取資料 $.post(........) 然後執行的時候報錯 “$ is no
selenium + python自動化測試unittest框架學習(三)webdriver對頁面其他控件操作(三)
文件的 文件路徑 內容 option selenium script web 對話 對話框 1.對話框,下拉框 (1)對話框的有兩種,一種是iframe格式的,需要switch_to_iframe()進行定位,現在大部分的對話框是div格式的,這種格式的可以通過層級定位來定
selenium + python自動化測試unittest框架學習(三)webdriver元素定位(一)
倒數 節點 大於 文本框 webdriver 而且 單標簽 unit 遍歷 1.Webdriver原理 webdirver是一款web自動化操作工具,為瀏覽器提供統一的webdriver接口,由client也就是我們的測試腳本提交請求,remote server瀏覽器進行響
selenium + python自動化測試unittest框架學習(一)selenium原理及應用
自動化 網上 下載安裝 src .cn 基礎 client cnblogs pytho unittest框架的學習得益於蟲師的《selenium+python自動化實踐》這一書,該書講得很詳細,大家可以去看下,我也只學到一點點用於工作中,閑暇時記錄下自己所學才能更加印象深刻
selenium + python自動化測試unittest框架學習(四)python導入模塊及包知識點
腳本 selenium imp pat 程序 文件 sel sys module 在寫腳本的時候,發現導入某些模塊,經常報錯提示導入模塊失敗,這裏來惡補下python導入模塊的知識點。 1.模塊導入時文件查找順序 在腳本中,import xxx模塊時的具體步驟: (1)新建
selenium python自動化測試 ddt數據驅動
span print pri testcase cep .text .cn 賬號 false 安裝ddt pip install ddt 直接上代碼: 1 # coding:utf-8 2 import ddt 3 import time 4 import e
selenium Python自動化 筆記 根據xpath找定位的響應屬性 修改鏈接並打開
print ram main import ttr body username div method # coding=utf-8import timeimport unittestfrom framework.browser_engine import BrowserEn
【python-excel】Selenium+python自動化之讀取Excel數據(xlrd)
logs title .html selenium2 ref target targe pos 數據 Selenium2+python自動化之讀取Excel數據(xlrd) 轉載地址:http://www.cnblogs.com/lingzeng86/p/6793398.h
selenium+python自動化77-autoit文件上傳【轉載】
關於 可用 功能 延遲 get tro sel cmd href 前言 關於非input文件上傳,點上傳按鈕後,這個彈出的windows的控件了,已經跳出三界之外了,不屬於selenium的管轄範圍(selenium不是萬能的,只能操作web上元素)。autoit工具處理w
selenium+python自動化78-autoit參數化與批量上傳【轉載】
Coding fmt def all 電腦 定位 ext for alt 轉至博客:上海-悠悠 前言前一篇autoit實現文件上傳打包成.exe可執行文件後,每次只能傳固定的那個圖片,我們實際測試時候希望傳不同的圖片。這樣每次調用的時候,在命令行裏面加一個文件路徑的參數就行
selenium+python自動化測試(一)環境
get gre gpo exe ren 瀏覽器版本 art lap close python裝的是3.5,chrome瀏覽器版本是17年初的 1.chromedriver 在http://chromedriver.storage.googleapis.com/index.h
selenium+python自動化測試(二)對瀏覽器的簡單操作
cat quit 報錯 簡單 conn port ted href ide 1.最大化 maximize_window 1 # coding = utf-8 2 3 from selenium import webdriver 4 chromedriver =
selenium+python自動化86-Chrome正在受到自動軟件的控制
tps ive bdr sele 討厭的 rom .com itl int 出現問題 1.用selenium啟動瀏覽器出現‘Chrome正在受到自動軟件的控制’ 2.如果不想看到這種討厭的提示語,啟動瀏覽器時候加個配置就行了 disable-infobars 1.在瀏覽器
selenium+python自動化89-用例不通過的時候發送郵件
exception 試用 一個 sel send post ttr htm ima 前言 實現需求:當測試用例全部通過的時候,不發郵件,當用例出現Error或Failure的時候發送郵件 解決思路:生成html測試報告後,用bs4解析html頁面,寫個函數判斷頁面上是都有不
selenium+python自動化93-鼠標事件(ActionChains)源碼詳解
cnblogs driver offset .py IT release and 鼠標位置 chains ActionChains簡介 actionchains是selenium裏面專門處理鼠標相關的操作如:鼠標移動,鼠標按鈕操作,按鍵和上下文菜單(鼠標右鍵)交互。 這對於
selenium+python自動化測試
href can 分享圖片 exit async nts details pri itl F12: 右鍵 選擇復制 path 在selenium+python自動化測試(一)–環境搭建中,運行了一個測試腳本,腳本內容如下: from selenium imp
selenium+python自動化79-文件下載(SendKeys)
bdr odin com utf-8 http rip 鼠標 setup Coding 前言 文件下載時候會彈出一個下載選項框,這個彈框是定位不到的,有些元素註定定位不到也沒關系,就當沒有鼠標,我們可以通過鍵盤的快捷鍵完成操作。 SendKeys庫是專業的處理鍵盤事件的,所
selenium+python自動化97--unittest參數化(paramunittest)
case 技術分享 下載地址 準備 自動生成 stl github 官方 pycharm 前言 paramunittest是unittest實現參數化的一個專門的模塊,可以傳入多組參數,自動生成多個用例前面講數據驅動的時候,用ddt可以解決多組數據傳入,自動生成多個測試用例