rod_utils.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. package common
  2. import (
  3. "errors"
  4. "git.listensoft.net/tool/jspkit/common/lxrod"
  5. "git.listensoft.net/tool/jspkit/common/models"
  6. "git.listensoft.net/tool/jspkit/common/watermark"
  7. "git.listensoft.net/tool/jspkit/logger"
  8. "git.listensoft.net/tool/jspkit/taxerr"
  9. "github.com/go-rod/rod"
  10. "github.com/go-rod/rod/lib/input"
  11. "github.com/go-rod/rod/lib/proto"
  12. "github.com/go-rod/rod/lib/utils"
  13. "go.uber.org/zap"
  14. "os"
  15. "strings"
  16. "time"
  17. )
  18. func MustHas(page *rod.Page, xpath string) bool {
  19. x, _, _ := HasX(page, xpath)
  20. return x
  21. }
  22. func MustHasX(page *rod.Page, xpath string) bool {
  23. x, _, _ := HasX(page, xpath)
  24. return x
  25. }
  26. func MustHasXV(page *rod.Page, xpath string) bool {
  27. for _, element := range MustElementsX(page, xpath) {
  28. visible, _ := element.Visible()
  29. if visible {
  30. return true
  31. }
  32. }
  33. return false
  34. }
  35. func MustElementX(page *rod.Page, xpath string) *rod.Element {
  36. for i := 0; i < 5; i++ {
  37. x, _ := ElementX(page, xpath)
  38. if x != nil {
  39. return x
  40. }
  41. utils.Sleep(1)
  42. }
  43. return nil
  44. }
  45. func MustHasXV1(page *rod.Page, xpath string) bool {
  46. for _, element := range MustElementsX1(page, xpath) {
  47. visible, _ := element.Visible()
  48. if visible {
  49. return true
  50. }
  51. }
  52. return false
  53. }
  54. func HasX(page *rod.Page, xpath string) (bool, *rod.Element, error) {
  55. var x *rod.Element
  56. var has bool
  57. var err error
  58. err = rod.Try(func() {
  59. has, x, err = page.HasX(xpath)
  60. if has {
  61. return
  62. }
  63. if err != nil {
  64. panic(err)
  65. }
  66. if has {
  67. return
  68. }
  69. iframe := GetAllIframe(page)
  70. for _, pg := range iframe {
  71. has, x, err = pg.HasX(xpath)
  72. if has {
  73. return
  74. }
  75. if err != nil {
  76. panic(err)
  77. }
  78. if has {
  79. return
  80. }
  81. }
  82. })
  83. if x != nil {
  84. x = x.Timeout(time.Second * 15)
  85. }
  86. return has, x, err
  87. }
  88. func ElementX(page *rod.Page, xpath string) (*rod.Element, error) {
  89. _, element, err := HasX(page, xpath)
  90. if err != nil {
  91. err = taxerr.NewWebStuckTitle(false)
  92. }
  93. return element, err
  94. }
  95. func GetAllIframe(page *rod.Page) []*rod.Page {
  96. fs := make([]*rod.Page, 0)
  97. if page.MustHasX(`//iframe`) {
  98. for _, element := range page.MustElementsX(`//iframe`) {
  99. fs = append(fs, element.MustFrame())
  100. fs = append(fs, GetAllIframe(element.MustFrame())...)
  101. }
  102. }
  103. return fs
  104. }
  105. func MustElementXV(page *rod.Page, xpath string) *rod.Element {
  106. for i := 0; i < 5; i++ {
  107. x, _ := ElementsX(page, xpath)
  108. for _, element := range x {
  109. visible, _ := element.Visible()
  110. if visible {
  111. return element
  112. }
  113. }
  114. utils.Sleep(1)
  115. }
  116. return nil
  117. }
  118. func MustElementsX(page *rod.Page, xpath string) (x []*rod.Element) {
  119. for i := 0; i < 5; i++ {
  120. x, _ = ElementsX(page, xpath)
  121. if len(x) != 0 {
  122. break
  123. }
  124. utils.Sleep(1)
  125. }
  126. return x
  127. }
  128. func MustElementsX1(page *rod.Page, xpath string) (x []*rod.Element) {
  129. x, _ = ElementsX(page, xpath)
  130. return x
  131. }
  132. func ElementsX(page *rod.Page, xpath string) ([]*rod.Element, error) {
  133. var arr []*rod.Element
  134. var err error
  135. err = rod.Try(func() {
  136. r, _ := page.Timeout(ClickTimeOut).ElementsX(xpath)
  137. if err != nil {
  138. panic(err)
  139. }
  140. arr = append(arr, r...)
  141. for _, pg := range GetAllIframe(page) {
  142. pg.MustWaitLoad()
  143. r, err = pg.Timeout(ClickTimeOut).ElementsX(xpath)
  144. if err != nil {
  145. panic(err)
  146. }
  147. arr = append(arr, r...)
  148. }
  149. })
  150. return arr, err
  151. }
  152. func WaitElementX(page *rod.Page, xpath string, interval float64) *rod.Element {
  153. for i := 0; i < 60; i++ {
  154. if has, el, _ := HasX(page, xpath); has {
  155. return el
  156. }
  157. time.Sleep(time.Duration(float64(time.Second) * interval))
  158. }
  159. return nil
  160. }
  161. func WaitNavigation(page *rod.Page, url string) {
  162. navigation := page.Timeout(time.Minute).MustWaitNavigation()
  163. page.Timeout(time.Minute).MustNavigate(url)
  164. logger.Info("调试埋点11-1")
  165. utils.Sleep(1)
  166. WaitTimeOut(navigation, time.Minute)
  167. logger.Info("埋点11-2")
  168. }
  169. func WaitTimeOut(f func(), timeout time.Duration) {
  170. resultChan := make(chan struct{}, 1)
  171. go func() {
  172. f()
  173. resultChan <- struct{}{}
  174. }()
  175. select {
  176. case <-resultChan:
  177. return
  178. case <-time.After(timeout):
  179. panic(taxerr.NewWebStuckTitle(ComInfo.Cscsts))
  180. }
  181. }
  182. func Link(p *rod.Page) {
  183. go func() {
  184. //for {
  185. //utils.Sleep(1)
  186. if p == nil {
  187. return
  188. }
  189. rod.Try(func() {
  190. lxrod.DialogWatch(nil, p)
  191. go p.Browser().EachEvent(func(e *proto.TargetTargetCreated) {
  192. defer func() {
  193. if r := recover(); r != nil {
  194. logger.Error("EachPageCreatedEvent recover:", zap.Any("r", r))
  195. }
  196. }()
  197. if e.TargetInfo.Type != proto.TargetTargetInfoTypePage {
  198. return
  199. }
  200. page := p.Browser().MustPageFromTargetID(e.TargetInfo.TargetID)
  201. lxrod.DialogWatch(nil, page)
  202. })()
  203. // has, _, _ := p.Has("dialog")
  204. // if has {
  205. // _, _ = p.Eval(`
  206. //window.alert = function() {};
  207. //window.confirm = function() { return true; };
  208. //window.prompt = function() {};`)
  209. // }
  210. })
  211. //}
  212. }()
  213. }
  214. // 有就点 没有就不点击
  215. func MustClick(page *rod.Page, xpath string) {
  216. x := MustElementsX(page, xpath)
  217. for _, element := range x {
  218. visible, _ := element.Visible()
  219. if visible {
  220. element.MustClick()
  221. break
  222. }
  223. }
  224. }
  225. func MustText(page *rod.Page, xpath string) string {
  226. //去掉左右空格
  227. return strings.TrimSpace(MustElementX(page, xpath).MustText())
  228. }
  229. // 输入文字
  230. func Input(p *rod.Page, selector, inputVal string) {
  231. err := rod.Try(func() {
  232. if inputVal == "" || inputVal == "*" {
  233. inputVal = "0"
  234. }
  235. e := rod.Try(func() {
  236. p.Timeout(time.Second).MustSearch(selector).MustSelectAllText().MustFrame().Keyboard.MustType(input.Backspace)
  237. })
  238. if e != nil {
  239. if w := errors.Unwrap(e); w != nil {
  240. logger.Info(w.Error() + "-" + selector + "-" + inputVal)
  241. } else {
  242. logger.Info(e.Error() + "-" + selector + "-" + inputVal)
  243. }
  244. }
  245. e = rod.Try(func() {
  246. p.Timeout(time.Second).MustSearch(selector).MustSelectAllText().MustInput(inputVal)
  247. })
  248. if e != nil {
  249. if w := errors.Unwrap(e); w != nil {
  250. logger.Info(strings.Split(w.Error(), "\t")[0] + "-" + selector + "-" + inputVal)
  251. } else {
  252. logger.Info(strings.Split(e.Error(), "\t")[0] + "-" + selector + "-" + inputVal)
  253. }
  254. }
  255. })
  256. if err != nil {
  257. logger.Info(err.Error() + "-" + selector + "-" + inputVal)
  258. }
  259. }
  260. // 输入文字
  261. func MustInputX(p *rod.Page, xPath, inputVal string) {
  262. e := MustElementX(p, xPath)
  263. _ = e.ScrollIntoView()
  264. e.MustClick().MustSelectAllText().MustInput(inputVal)
  265. }
  266. // 拦截请求
  267. func PageHijackReq(b *rod.Page, pattern string, ch chan []byte) *rod.HijackRouter {
  268. router := b.HijackRequests()
  269. router.MustAdd(pattern, func(ctx *rod.Hijack) {
  270. rod.Try(func() {
  271. ctx.MustLoadResponse()
  272. ch <- []byte(ctx.Response.Body())
  273. utils.Sleep(5)
  274. select {
  275. case <-ch:
  276. break
  277. }
  278. })
  279. })
  280. go router.Run()
  281. return router
  282. }
  283. // 获取拦截请求的值
  284. func GetHijackResp(ch chan []byte, t float64) ([]byte, error) {
  285. d := time.Duration(t * float64(time.Second))
  286. select {
  287. case val := <-ch:
  288. return val, nil
  289. case <-time.After(d):
  290. return nil, errors.New("请求网页超时,请稍后重试!")
  291. }
  292. }
  293. // WaitForPageLoad 等待页面完全加载,selector 为等待某个元素加载的选择器,可选
  294. func WaitForPageLoad(page *rod.Page, timeoutDuration time.Duration, selector ...string) {
  295. start := time.Now()
  296. // 1. 等待页面 readyState 为 "complete",加上超时控制
  297. for {
  298. readyState := page.MustEval(`() => document.readyState`).String()
  299. if readyState == "complete" {
  300. break // 页面加载完成,退出循环
  301. }
  302. // 检查是否超时
  303. if time.Since(start) > timeoutDuration {
  304. break
  305. }
  306. time.Sleep(500 * time.Millisecond) // 每次检查之间等待一段时间
  307. }
  308. // 2. 等待页面元素稳定
  309. page.MustWaitStable()
  310. // 3. 如果传入了 selector,等待特定元素加载完成
  311. if len(selector) > 0 {
  312. rod.Try(func() {
  313. page.Timeout(timeoutDuration).MustElement(selector[0]) // 使用传入的选择器等待元素
  314. })
  315. }
  316. // 4. 等待所有网络请求结束
  317. rod.Try(func() {
  318. page.Timeout(timeoutDuration).MustWaitIdle()
  319. })
  320. utils.Sleep(3)
  321. }
  322. func WaitHasX(page *rod.Page, xpath string) (x bool) {
  323. for i := 0; i < 5; i++ {
  324. x, _, _ = HasX(page, xpath)
  325. if !x {
  326. utils.Sleep(1)
  327. }
  328. }
  329. return x
  330. }
  331. func SaveErrImg(p *rod.Page, info models.CompanyInfo) string {
  332. var check_path string
  333. check_path = "./data/sbImg/" + info.TaxNo + "/"
  334. if !PathExists(check_path) {
  335. os.MkdirAll(check_path, os.ModePerm)
  336. }
  337. check_path = check_path + info.Period + "-" + time.Now().Format("2006-01-02-15-04-05") + ".png"
  338. check_path2 := ""
  339. _ = rod.Try(func() {
  340. p.Timeout(ClickTimeOut).MustScreenshot(check_path)
  341. watermark.Add(check_path)
  342. check_path2 = PostSbjt(info.TaxNo, info.Period, check_path)
  343. os.Remove(check_path)
  344. })
  345. return check_path2
  346. }
  347. // InputWithTimeout 规定时间内填入输入值,默认5s
  348. func InputWithTimeout(p *rod.Page, selector, inputVal string, timeout ...int64) {
  349. var t int64
  350. if len(timeout) == 0 {
  351. t = 5
  352. } else {
  353. t = timeout[0]
  354. }
  355. p.Timeout(time.Duration(t) * time.Second).MustSearch(selector).MustSelectAllText().MustInput(inputVal)
  356. }
  357. func SaveErrImgTask(p *rod.Page, info *models.TaxTask) string {
  358. var check_path string
  359. check_path = "./data/sbImg/" + info.TaxNo + "/"
  360. if !PathExists(check_path) {
  361. os.MkdirAll(check_path, os.ModePerm)
  362. }
  363. check_path = check_path + info.Period + "-" + time.Now().Format("2006-01-02-15-04-05") + ".png"
  364. var check_path2 string
  365. _ = rod.Try(func() {
  366. p.Timeout(ClickTimeOut).MustScreenshot(check_path)
  367. watermark.Add(check_path)
  368. check_path2 = PostSbjt(info.TaxNo, info.Period, check_path)
  369. os.Remove(check_path)
  370. })
  371. return check_path2
  372. }
  373. // 使用键盘模拟输入
  374. func InputStrNew(page *rod.Page, el *rod.Element, str string) {
  375. el.MustScrollIntoView()
  376. box := el.MustShape().Box()
  377. Click(page, box.X+(box.Width/2), box.Y+(box.Height/2))
  378. time.Sleep(time.Millisecond * 100)
  379. selectAll2(page)
  380. time.Sleep(time.Millisecond * 100)
  381. _ = page.Keyboard.Type(input.Delete)
  382. _ = page.Keyboard.Type(input.Backspace)
  383. time.Sleep(time.Millisecond * 100)
  384. _ = page.Keyboard.Type(input.Backspace)
  385. for _, v := range str {
  386. _ = page.Keyboard.Type(input.Key(v))
  387. time.Sleep(time.Millisecond * 100)
  388. }
  389. }
  390. func Click(page *rod.Page, x, y float64) {
  391. page.Mouse.MustMoveTo(x, y)
  392. time.Sleep(time.Millisecond * 100)
  393. page.Mouse.MustDown("left")
  394. page.Mouse.MustUp("left")
  395. }
  396. func selectAll2(page *rod.Page) {
  397. page.Keyboard.MustType(input.ControlLeft).MustType('a').MustType('a').MustType(input.ControlLeft)
  398. }
  399. // 输入文字Str
  400. func InputStr(p *rod.Page, selector, inputVal string) {
  401. err := rod.Try(func() {
  402. e := rod.Try(func() {
  403. p.Timeout(time.Duration(1 * float64(time.Second))).MustSearch(selector).MustSelectAllText().MustFrame().Keyboard.MustType(input.Backspace)
  404. })
  405. if e != nil {
  406. logger.Info(e.Error() + "-" + selector + "-" + inputVal)
  407. }
  408. e = rod.Try(func() {
  409. p.Timeout(time.Duration(1 * float64(time.Second))).MustSearch(selector).MustSelectAllText().MustInput(inputVal)
  410. })
  411. if e != nil {
  412. logger.Info(strings.Split(e.Error(), "\t")[0] + "-" + selector + "-" + inputVal)
  413. }
  414. })
  415. if err != nil {
  416. logger.Info(err.Error() + "-" + selector + "-" + inputVal)
  417. }
  418. }
  419. // 输入文字 string
  420. func InputElementXStr(p *rod.Page, xPath, inputVal string) {
  421. elementX := MustElementX(p, xPath)
  422. disabled := elementX.MustAttribute("disabled")
  423. if disabled != nil {
  424. return
  425. }
  426. readonly := elementX.MustAttribute("readonly")
  427. if readonly != nil {
  428. return
  429. }
  430. elementX.MustSelectAllText().MustInput(inputVal)
  431. }
  432. func WaitElementXFoTimesNil(page *rod.Page, xpath string, times int) *rod.Element {
  433. for i := 0; i < times; i++ {
  434. if has, el, _ := HasX(page, xpath); has && MustElementX(page, xpath).MustVisible() {
  435. return el
  436. }
  437. time.Sleep(time.Second)
  438. }
  439. return nil
  440. }
  441. func MustElementX10(page *rod.Page, xpath string) *rod.Element {
  442. for i := 0; i < 10; i++ {
  443. x, _ := ElementX(page, xpath)
  444. if x != nil {
  445. return x
  446. }
  447. utils.Sleep(1)
  448. }
  449. return nil
  450. }
  451. func MustElementX15(page *rod.Page, xpath string) *rod.Element {
  452. for i := 0; i < 15; i++ {
  453. x, _ := ElementX(page, xpath)
  454. if x != nil {
  455. return x
  456. }
  457. utils.Sleep(1)
  458. }
  459. return nil
  460. }
  461. func MustHasXV30(page *rod.Page, xpath string) bool {
  462. for _, element := range MustElementsX30(page, xpath) {
  463. visible, _ := element.Visible()
  464. if visible {
  465. return true
  466. }
  467. }
  468. return false
  469. }
  470. func MustElementsX30(page *rod.Page, xpath string) (x []*rod.Element) {
  471. for i := 0; i < 30; i++ {
  472. x, _ = ElementsX(page, xpath)
  473. if len(x) != 0 {
  474. break
  475. }
  476. utils.Sleep(1)
  477. }
  478. return x
  479. }
  480. func WaitElementXFoTimes(page *rod.Page, xpath string, times int) *rod.Element {
  481. for i := 0; i < times; i++ {
  482. if has, el, _ := HasX(page, xpath); has && MustElementX(page, xpath).MustVisible() {
  483. return el
  484. }
  485. time.Sleep(time.Second)
  486. }
  487. logger.Info("页面加载失败元素未找到,请稍后再试", xpath)
  488. panic(taxerr.NewWebStuckTitle(InfoCscsts))
  489. }
  490. func MustElementsX10(page *rod.Page, xpath string) (x []*rod.Element) {
  491. for i := 0; i < 10; i++ {
  492. x, _ = ElementsX(page, xpath)
  493. if len(x) != 0 {
  494. break
  495. }
  496. utils.Sleep(1)
  497. }
  498. return x
  499. }
  500. func WaitMustElementsX(page *rod.Page, xpath string) (elementsX []*rod.Element) {
  501. for i := 0; i < 5; i++ {
  502. elementsX = MustElementsX(page, xpath)
  503. if len(elementsX) != 0 {
  504. return
  505. }
  506. utils.Sleep(1)
  507. }
  508. return
  509. }
  510. func ClickB(page *rod.Page, el string) {
  511. box := MustElementX(page, el).MustShape().Box()
  512. Click(page, box.X+(box.Width/2), box.Y+(box.Height/2))
  513. }
  514. func WaitElementX10(page *rod.Page, xpath string) *rod.Element {
  515. return WaitElementXFoTimes(page, xpath, 10)
  516. }
  517. func MustElementX30(page *rod.Page, xpath string) *rod.Element {
  518. for i := 0; i < 30; i++ {
  519. x, _ := ElementX(page, xpath)
  520. if x != nil {
  521. return x
  522. }
  523. utils.Sleep(1)
  524. }
  525. return nil
  526. }
  527. func WaitHasX10(page *rod.Page, xpath string) (x bool) {
  528. for i := 0; i < 10; i++ {
  529. x, _, _ = HasX(page, xpath)
  530. if !x {
  531. utils.Sleep(1)
  532. }
  533. }
  534. return x
  535. }
  536. // 返回当前元素下一个元素的text 如果没有元素就直接返回空
  537. func MustNextText(page *rod.Page, xpath string) string {
  538. x := MustElementXV(page, xpath)
  539. if x == nil {
  540. return ""
  541. }
  542. return x.MustNext().MustText()
  543. }
  544. // 2033年12月31日 // 2033-12-31
  545. func DataFormat(data string) string {
  546. strings.ReplaceAll(data, "年", "-")
  547. strings.ReplaceAll(data, "月", "-")
  548. strings.ReplaceAll(data, "日", "")
  549. if len(data) > 10 {
  550. data = data[:10]
  551. }
  552. return data
  553. }
  554. // 返回当前元素下一个元素的text 如果没有元素就直接返回空
  555. func MustNext2Text(page *rod.Page, xpath string) string {
  556. x := MustElementXV(page, xpath)
  557. if x == nil {
  558. return ""
  559. }
  560. return x.MustNext().MustNext().MustText()
  561. }
  562. // 拦截
  563. func HijackReq(page *rod.Page, uri, xPath string) []byte {
  564. ch := make(chan []byte)
  565. r := PageHijackReq(page, uri, ch)
  566. MustElementX(page, xPath).MustClick()
  567. data, err := GetHijackResp(ch, 10)
  568. if err != nil {
  569. panic(taxerr.NewWebStuckTitle(false))
  570. }
  571. _ = r.Stop()
  572. return data
  573. }
  574. // 输入文字 float
  575. func InputElementX(p *rod.Page, xPath, inputVal string) {
  576. disabled := MustElementX(p, xPath).MustAttribute("disabled")
  577. if disabled != nil {
  578. return
  579. }
  580. readonly := MustElementX(p, xPath).MustAttribute("readonly")
  581. if readonly != nil {
  582. return
  583. }
  584. float := StrToFloat(inputVal)
  585. if float == 0 {
  586. inputVal = ""
  587. } else {
  588. inputVal = FloatToStr(float)
  589. }
  590. MustElementX(p, xPath).MustSelectAllText().MustInput(inputVal)
  591. }
  592. func GetText(page *rod.Page, selector string) string {
  593. return page.Timeout(ClickTimeOut).MustSearch(selector).MustText()
  594. }
  595. func WaitHasX15(page *rod.Page, xpath string) (x bool) {
  596. for i := 0; i < 15; i++ {
  597. x, _, _ = HasX(page, xpath)
  598. if !x {
  599. utils.Sleep(1)
  600. }
  601. }
  602. return x
  603. }
  604. // 这个方法存在bug 如果新页面没加载完,爬出异常了,就会存在新页面没关闭的情况
  605. func WaitTimeOutPage(f func() *rod.Page, timeout time.Duration) *rod.Page {
  606. resultChan := make(chan *rod.Page, 1)
  607. go func() {
  608. page := f()
  609. resultChan <- page
  610. }()
  611. select {
  612. case p := <-resultChan:
  613. return p
  614. case <-time.After(timeout):
  615. panic(taxerr.NewWebStuckTitle(ComInfo.Cscsts))
  616. }
  617. }
  618. func MustHasXV10(page *rod.Page, xpath string) bool {
  619. for _, element := range MustElementsX10(page, xpath) {
  620. visible, _ := element.Visible()
  621. if visible {
  622. return true
  623. }
  624. }
  625. return false
  626. }
  627. // 输入文字 string 有的公司有 有的公司没有 工商
  628. func InputElementXStrOrNo(p *rod.Page, xPath, inputVal string) {
  629. elementX := MustElementX(p, xPath)
  630. if elementX == nil {
  631. return
  632. }
  633. disabled := elementX.MustAttribute("disabled")
  634. if disabled != nil {
  635. return
  636. }
  637. readonly := elementX.MustAttribute("readonly")
  638. if readonly != nil {
  639. return
  640. }
  641. elementX.MustSelectAllText().MustInput(inputVal)
  642. }