ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¦p¦ó¥ÎEXCEL VBA¦bCHROME¿é¤J¸ê®Æ¦A«ö¤U¬d¸ß¡H

[µo°Ý] ¦p¦ó¥ÎEXCEL VBA¦bCHROME¿é¤J¸ê®Æ¦A«ö¤U¬d¸ß¡H

½Ð±Ð¦U¦ì¤j¯«¡A§Ú·Q¥ÎVBA§ì¤½¥qºô­¶¸ê®Æ¡A¤§«e³£¬O¥ÎIE¡A»yªk¤W¤j·§¤F¸Ñ«ç»ò¼g¡A¦ý²{¦b¤½¥qIE°±¥Î¤F¡A¥u¯à¥ÎCHROME¡A§Ú¥Ø«e¥u¯à¼g¨ì¶}±ÒCHROMEºô­¶¡A¦ý¬O¦p¦ó¾Þ§@¿é¤J¼Æ¦r«ö¤U¬d¸ß¬O§¹¥þ¨S¦³ÀYºü¡Aªþ¤W¶}±ÒCHROMEªºµ{¦¡½X¥H¤ÎºI¹Ï¡AÀµ½Ð¦U¦ì¤j¯«À°¦£¸Ñ´b¡A¸U¤À·PÁ¡C
PS:¥Ñ©óµ{¦¡½X¤ºªººô§}¬O¤½¥q¤º³¡ºô­¶¡A©Ò¥H¦U¦ì¤j¯«¦b´ú¸Õªº®É­Ô¨S¿ìªk¥Ñ¥~³¡¶}±Ò¡AÁٽШ£½Ì¡C
  1. Sub test()
  2. Dim Chrome As New Selenium.ChromeDriver
  3. Dim URL As String
  4. URL = http://etrex2:8080/SelectWeb/
  5. With Chrome
  6.     .Get URL
  7. End With
  8. End Sub
½Æ»s¥N½X

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2022-7-12 16:29 ½s¿è

¦^´_ 10# smart3135



1.§A³o­Ó¦³frame
https://club.excelhome.net/thread-1452021-3-1.html
°Ñ¦Ò30¼Ó ¦A¤£¦æ ª½±µgoogle ¥Î¯Â­^¤å §ä¬Ý¬Ý¦³¨S¦³½d¨Ò


2.¨S¿ìªk ¥u¯à¦h¦¸§Q¥Î set tag1 = chrome.findelementsbytag("xxx")(0)   ¤@¼h¤@¼hºCºC©¹¤UÃä´úÃä§ä
xxx ´N¬O³Ì«e­±<> ¤¤ªºµµ¦â¤å¦r  ¨Ò¦p center form table tbody tr td input
(0) ¬Ýª«¥ó²Õ¤ºªº²Ä´X­Ó¬O§A­nªº ¥i¥H¥Î°j°é ©ÎªÌ.text ©Î.value ¨Ódebug.print ½T»{¬O¤£¬O§A­nªº¸Ó¤¸¥ó

Ãä§ä¤]¥i¥HÃB¥~ §Q¥Î   °j°é + instr + .attribute  ªº¤è¦¡¼Ò½k·j¯Á

TOP

¦^´_  smart3135


¨ä¹ê¥i¥H¤£¥Î«öF12

(¥kÁä>Àˬd)°µ¨â¦¸    ¤£¬O¥kÃ䪺¬õ®Ø,¦Ó¬O¥ªÃ䪺Åã¥Üµe­± ...
singo1232001 µoªí©ó 2022-7-11 03:43

±z¦n¡A¤µ¤Ñ¨ì¤½¥q¥Î¤F·Æ¹«¥kÁä¿ïÀˬd¡A¯uªº¯à§ä¨ì¹ïÀ³ªº¤¸¥ó¤º®e¡A¥u¬OÁÙ¬O¤£¬O«Ü²M·¡³o­ÓFindElement¸Ó«ç»ò¼g¡A¥i§_¦A³Â·Ð±zÀ°¦£¬Ý¤@¤U¡A­YÁٻݭn¨ä¥L¸ê°T½Ð¦A§iª¾¡A«D±`·PÁ±z¡C

1.­º¥ý²{¦bSearchÂI¤@¤U



2.¦b½Ð¿é¤J¤u³æ¸¹½XÄæ¦ì¿é¤J¤u³æ¸¹½X


3.«ö¤U¬d¸ß§Y¥i±o¨ìµ²ªG

TOP

¥»©«³Ì«á¥Ñ quickfixer ©ó 2022-7-11 05:51 ½s¿è

¦^´_ 8# singo1232001


    1.¥t¥~«Øij ¦b½s¼g¹Lµ{ ¤d¸U¤£­n¥Îwith ªº¼gªk ³o·|³y¦¨§A´ú¸Õ³Â·Ð

¬Ý¼Ó¥Dªºµ{¦¡½X,¥Îwithµ²ºcº}«G,¤]¥u¥Î¤F1­Ó,¤£·|¦³°ÝÃD
§Úgoogle¨ì¥Îwith¥u¦³¦n³B
§Ú¤£¹³§A³o»òºë³qµ{¦¡,·d¤£²M·¡³o´X¦æµ{¦¡½X·|¥X¤°»ò°ÝÃD
½Ð±Ð¤@¤U³oºØwith¼gªk·|¥X²{¤°»ò³Â·Ð?


https://docs.microsoft.com/zh-tw/dotnet/visual-basic/language-reference/statements/with-end-with-statement
¦pªG±zªºµ{¦¡½X·|¦b¦h­Ó³¯­z¦¡¤¤¦s¨ú¬Û¦Pª«¥ó¡A¨Ï¥Î With ³¯­z¦¡¦³¤U¦C¦n³B¡G

±z¤£»Ý­n¦h¦¸µû¦ô½ÆÂøªº¹Bºâ¦¡©Î«ü¬£µ²ªGµ¹¼È¦sÅܼơA¥H¦h¦¸°Ñ¦Ò¨ä¦¨­û¡C

±z¥i¥HÅýµ{¦¡½X§ó®e©öŪ¨ú¡A¤èªk¬O±Æ°£­«½Æªº­­©w¹Bºâ¦¡¡C

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2022-7-11 03:58 ½s¿è

¦^´_ 7# smart3135


¨ä¹ê¥i¥H¤£¥Î«öF12

(¥kÁä>Àˬd)°µ¨â¦¸    ¤£¬O¥kÃ䪺¬õ®Ø,¦Ó¬O¥ªÃ䪺Åã¥Üµe­±¤Wª½±µ¾Þ§@

¤¤¤åª©ªº¬O"Àˬd"  ­^¤åª©ªº§Ú§Ñ¤F




­Yµe­±¦³«ÊÂê  ´N­n¥ýF12 µM«á¥kÃ䪺µ{¦¡½X  ¥Î·Æ¹«¤W¤U²¾°Ê  ¬Ý¥ªÃäµe­±­þ¸Ì³Q®Ø°_¨Ó ´N¯à³vº¥§ä¨ì

©ÎªÌ¦w¸Ëgoogle chrome°Ó©±ªº Selenium IDE ÂX¥R¥\¯à ¨Ó§ì(¹J¨ìÂëܲ`ªº¤~»Ý­n)

¤ñ¦p§A»¡ªº¨º­Ó·j´MÄæ´N¬O
chrome.FindElementById("header-search-input").clear
chrome.FindElementById("header-search-input").sendkey "ÃöÁä¦r"
ÂIÀ»¬d¸ß«ö¶s
chrome.FindElementById("header-desktop-search-button").click





1.¥t¥~«Øij ¦b½s¼g¹Lµ{ ¤d¸U¤£­n¥Îwith ªº¼gªk ³o·|³y¦¨§A´ú¸Õ³Â·Ð
2.ID³q±`¥u¦³1­Ó ©Ò¥H«Ü¦n¤Ö
3.«DIDªº¤¸¥ó ³q±`¤£¥u1­Ó  ´N¥i¥H+s
¨Ò¦p:
set tag1 = chrome.FindElementByTag("input")   ³o­¶­±¦Ü¤Ö¶W¹L10­Ó¥H¤W
´N¸Ó§ï¦¨
set tag1 = chrome.FindElementsByTag("input")

³o¼Ë´N¯à¦b¤§«á§â©Ò¦³ªºinput ³£©ñ¤J tag1 ¤º ¨Ã¹³°}¦Cª«¥ó¤@¼Ë ·|¦Û°Ê½s¸¹

¤§«á´N¥i¥H³æ¿W¿ï¾Ü
tag1(0)
tag1(1)
.
.
.
.
.
tag1(tag1.count) ¤ºªºªF¦è¤F





¸É¥R
­n¤£­nset ´N¬Ý§A¤§«áÁÙ­n¤£­nÄ~Äò¥Î
¦p¤W­z¨Ò¤l
chrome.FindElementById("header-search-input").clear
chrome.FindElementById("header-search-input").sendkey "ÃöÁä¦r"
·í¤Usendkey ©ÎªÌclick ´N¨S¥²­nÃB¥~set
·íµM ¤]¥i¥H
set id1 = chrome.FindElementById("header-search-input")
id1.clear
id1.sendkey "ÃöÁä¦r"

TOP

¦^´_  smart3135


    ¦b¤¸¥ó¤W Àˬd¨â¦¸ ¤~·|¥þ®i¶}

    ²Ä¤@¦¸¥u·|¿ï¾Ü¨ì¤¸¥óªº¤W¼h©ÎªÌ®Ø¬[
   ...
singo1232001 µoªí©ó 2022-7-10 01:30

¥i¥H¦A©M±z½T»{¤@¤U¶Ü¡H¬O¥ªÁä¨â¦¸ÁÙ¬O¥kÁä¨â¦¸¡H§Ú«ö¥kÁä·|¥X²{¹Ï¤¤¬õ®Øªºµøµ¡¡C

TOP

¦^´_ 5# smart3135


    ¦b¤¸¥ó¤W Àˬd¨â¦¸ ¤~·|¥þ®i¶}

    ²Ä¤@¦¸¥u·|¿ï¾Ü¨ì¤¸¥óªº¤W¼h©ÎªÌ®Ø¬[
    ²Ä¤G¦¸¤~·|¦Û°Ê¸õ¨ì¤¸¥ó¥»¨­

TOP

¥»©«³Ì«á¥Ñ smart3135 ©ó 2022-7-10 00:32 ½s¿è
¦^´_  smart3135


»Ý­nªþ¤W ¨º¨â­Ó¤¸¥óªº¬ÛÃö¸ê°T  ¨Ò¦pID  class  tagname   
     
­n¦bÂsÄý¾¹«öF ...
singo1232001 µoªí©ó 2022-7-9 18:05

±z¦n¡A­ì¨Ó§Ú¤@¶}©l´N·d¿ù¤F¡A¤£¬O¦bºô­¶«ö¥kÁä¿ïÀˬdºô­¶­ì©l½X¡A¦Ó¬O­n«öF12¬d¤¸¥ó¡A«á¨Ó¦³¸ß°Ý¨ì¡AÀ³¸Ó¬O­n¥Î.FindElementById¡B.FindElementByName¡B.FindElementByXPathªº»yªk¡A¦p¤U­±¥ÎYahoo©_¼¯­º­¶·j´Mªº¨Ò¤l
  1. Sub test()
  2.     Dim chrome As New Selenium.ChromeDriver, UrL As String, s  As String
  3.     UrL = "https://tw.yahoo.com/"
  4.     s = "§¿¥¬"
  5.         With chrome
  6.         .Get UrL
  7.         .FindElementById("header-search-input").SendKeys (s)
  8.         .FindElementById("header-desktop-search-button").Click
  9.        End With
  10.      Stop
  11.      chrome.Quit
  12.     Set chrome = Nothing
  13.     End Sub
½Æ»s¥N½X
¥H©_¼¯³o­Ócase¨Ó»¡¡A¤¸¥ó¬O¥ÎID¡A©Ò¥H¬O¥Î.FindElementById¡A¤U¶g¨ì¤½¥q·|¦A¥ÎF12¬d¸ß¤@¦¸¤¸¥óªº¬ÛÃö¸ê°T¦Aªþ¤W¹Ï¤ù¡A¦b¦¹¤§«e¦³´X­ÓºÃ°Ý·Q¥ý½Ð±Ð±z
1.¦b©_¼¯­º­¶¡A§Ú«ö¤UF12¡A¤@¶}©l¨Ã¨S¿ìªk§ä¨ì"header-search-input"©M"header-desktop-search-button"³o¨â­ÓÃöÁäµü¡A¬Oµ¥«ö¤UCrl+F·j´M®Ø¥X²{«ákey¤Jsearch«á¤~¥X²{¡A¤£¤Ó²z¸Ñ¬°¤°»ò­n¦b³o¼Ë¾Þ§@«á¤~·|¥X²{ÃöÁäµü¡A§Ú³o¼Ëªº§@ªk¬O¥¿½Tªº¶Ü¡H©Î¬O¦³¨ä¥L¤ñ¸û¥¿½Tªº¤èªk¥i¥H¬d¨ì"header-search-input"©M"header-desktop-search-button"³o¨â­ÓÃöÁäµü¡H

2.±z»¡¦b·Q¬dªº¤¸¥ó¤W­±         ¥kÁä  >Àˬd (­«½Æ2¦¸)¡A³o¸Ì¤£¬O«ÜÀ´¡A¥i¥H¦A¸Ô­z¤@¤U©Î¬O´£¨Ñ°Ñ¦Ò¹Ï¤ù¶Ü¡H
¥ý·PÁ±zªº«ü¾É

TOP

¦^´_  smart3135


https://github.com/florentbr/SeleniumBasic/releases
¤U¸ü
SeleniumBasic-2.0.9 ...
singo1232001 µoªí©ó 2022-7-9 16:39


·PÁ±z´£¨Ñªº³o¨Ç¸ê°T¡A·|¦A¦n¦n®ø¤Æ¤@¤U¡C

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2022-7-9 18:09 ½s¿è

¦^´_ 1# smart3135


»Ý­nªþ¤W ¨º¨â­Ó¤¸¥óªº¬ÛÃö¸ê°T  ¨Ò¦pID  class  tagname   
     
­n¦bÂsÄý¾¹«öF12  ¨Ã¦b·Q¬dªº¤¸¥ó¤W­±         ¥kÁä  >Àˬd (­«½Æ2¦¸)

¤×¨ä¬O¬Y¨Ç¤º³¡ºô­¶Âîج[ ´Nºâ¤W­z §A¦³µ¹

¤]¥i¯à¦]¬°iframe¤£¦P®Ø¬[ µLªk¥Î  ¦ý¥i¥H¥ý¸Õ¸Õ

¥t¥~¸É¥R ¦³ID²³æ¤@ÂI
¨SID ´N­n¶¶µÛ ¯ª®]¶¥¼h ®i¶}¥þ§ì

TOP

        ÀR«ä¦Û¦b : ¡i¥Í©R¦b©I§l¶¡¡j¦òªû»¡¡G¡u¥Í©R¦b©I§l¶¡¡C¡v¤HµLªkºÞ¦í¦Û¤vªº¥Í©R¡A§óµLªk¾×¦í¦º´Á¡AÅý¦Û¤v¥Ã¦í¤H¶¡¡C¬JµM¥Í©R¥h¨Ó³o»òµL±`¡A§Ú­Ì§óÀ³¸Ó¦n¦n¦a·R±¤¥¦¡B§Q¥Î¥¦¡B¥R¹ê¥¦¡AÅý³oµL±`¡BÄ_¶Qªº¥Í©R¡A´²µo¥¦¯uµ½¬üªº¥ú½÷¡A¬M·Ó¥X¥Í©R¯u¥¿ªº»ù­È¡C
ªð¦^¦Cªí ¤W¤@¥DÃD