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

[¤À¨É] Âà´«ieª«¥ó»yªk¬°Selenium(chrome) ?

¥»©«³Ì«á¥Ñ t8899 ©ó 2022-9-25 09:44 ½s¿è

¦^´_ 10# singo1232001

½Ð±Ð¬Ýºô­¶­ì©l½X?¥Î¤°»ò¤èªk¬Ý¡A¸û®e©ö§ä¨ì¼ÐÃD??
/td /tr ³o¬O¤@¼h¤@¼h???¦³µL¥ý«á¦¸§Ç?¦p¦ó§Ö³tª¾¹D­n§äªºtable ¦b²Ä´X­Ó??
§äªº§Þ¥©?

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2022-9-25 10:27 ½s¿è

¦b§A·Q§äªººô­¶¦P¤@­Ó¦ì¸m
°µ¨â¦¸¡]«ö¥kÁä>Àˬd¡^

²Ä¤@¦¸¬O¶}±Ò ²Ä¤G¦¸¬O®i¶}¨ì§Aªº¤¸¯À

TOP

¦^´_ 10# singo1232001
½Ð±Ð§Ú­Y¦P®É­n¶}²Ä¤Gµøµ¡¡A­n¦A¼W¥[ Set driver = CreateObject("Selenium.ChromeDriver")  ³o¦æ ¬°
Set driver2 = CreateObject("Selenium.ChromeDriver")  ???

TOP

¦^´_ 12# singo1232001

https://mis.taifex.com.tw/futures/disclaimer
³oºô­¶¶i¤J«ö"±µ¨ü"«ç»ò¼g?

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2022-10-13 20:14 ½s¿è

¦^´_ 13# t8899

F8³v¨B´ú¸Õ

Sub test()
Set driver = CreateObject("Selenium.ChromeDriver")
driver.Get "https://www.google.com.tw/"
driver.ExecuteScript ("window.open()")
driver.SwitchToNextWindow
driver.Get "https://www.yahoo.com.tw/"
driver.Wait 1000
driver.Close
driver.Wait 1000
driver.SwitchToPreviousWindow
driver.Close
End Sub

TOP

¦^´_ 14# t8899


    Sub test2()
Set driver = CreateObject("Selenium.ChromeDriver")
driver.Get "https://mis.taifex.com.tw/futures/disclaimer/"
Set btnS = driver.findelementsbytag("button")
Debug.Print btnS(3).Text
btnS(3).Click
End Sub

TOP

¥»©«³Ì«á¥Ñ t8899 ©ó 2022-10-14 06:41 ½s¿è
¦^´_  t8899


    Sub test2()
Set driver = CreateObject("Selenium.ChromeDriver")
driver.Get "h ...
singo1232001 µoªí©ó 2022-10-13 20:11

ÁÂÁ«ü¾É
1.§Ú·Q¥[¤@­Ó °²¦p¤£¬O³o­Óºô­¶«h¸õ¹L   (goto)
2.§Ú¥Î driver.find_element_by_xpath(//*[@id="content"]/main/div[2]/div[2]/button[1].click())
¿ù»~°±¯d¬õ¦â³B??

Snap1.jpg (110.06 KB)

Snap1.jpg

TOP

¥»©«³Ì«á¥Ñ t8899 ©ó 2022-10-14 06:43 ½s¿è
¦^´_  t8899

F8³v¨B´ú¸Õ

Sub test()
Set driver = CreateObject("Selenium.ChromeDriver")
driver ...
singo1232001 µoªí©ó 2022-10-13 20:07


driver.SwitchToNextWindow
³o¦æªº»yªk¥i§_§ï¦¨¥Î"µøµ¡ªº¦W¦r"¤Á´«? ©Î¬Oª½±µ¹ï²Ä´X­Óµøµ¡°µ°Ê§@?

TOP

Sub test()
Set driver = CreateObject("Selenium.ChromeDriver")
driver.Get "http://forum.twbts.com/thread-23777-1-1.html"
w1 = driver.Title
driver.ExecuteScript ("window.open()")
driver.SwitchToNextWindow
driver.Get "https://www.yahoo.com.tw/"
w2 = driver.Title
driver.ExecuteScript ("window.open()")
driver.SwitchToNextWindow
driver.Get "https://www.mobile01.com/"
w3 = driver.Title
driver.Wait 2000
driver.SwitchToWindowByTitle w1
driver.Wait 5000
driver.SwitchToWindowByTitle w2
driver.Wait 5000
driver.SwitchToWindowByTitle w3
driver.Wait 5000
driver.Close
End Sub

TOP

¥»©«³Ì«á¥Ñ singo1232001 ©ó 2022-10-15 03:16 ½s¿è

¦^´_ 18# t8899

1
§PÂ_ºô­¶ ¥i¥H¥Îif §PÂ_¦¡
¸ÕµÛ¥Î¸Ì­±ªº ª«¥ó¦s¦bª¬ºA or ª«¥ó¼Æ¶q or ª«¥ó¦WºÙ or ª«¥ó¤å¦r or ºô­¶Title¦WºÙ(¥i¯à­«½Æ­n¬Ý­Ó®×) ¨Ó§PÂ_¸õ¹L
¥i¥H¥ý¤Uon error resume next ©¿²¤¿ù»~
¥H¤U¥i¨Ñ¬D¿ï§PÂ_¤è¦¡
±Ò¥Î¥i¥H¥Îisobject() =true
¼Æ¶q¥Î.count>0
¦WºÙ¥Î.attribute
¤å¦r¥Î.text
ºô­¶title¦WºÙ ¥Î.title
¤W­z¤å¦r¥i¥H·f°tvbaªºinstr like find ³o¦C¤å¦r·j¯Áªº¥\¯à°µ§PÂ_

2
xpath§Ú¤£¤Ó±`¥Î ©Ò¥H½mªº¤£¼ô §Ú²ßºD¥Îtag§ì¦ì¸m ³q±`«Ü°ªªº°ª¤â·|¥Îxpath ©ÎªÌ¹B®ð¤£¿ù­è¦n¯à¥Î(¸Ó¤¸¯À¨S¦³«áÄò¤~ºCºC¥X²{)
¥D­n­ì¦]¬O ¦³®É­Ô ºô­¶¤£·|¤@¦¸©Ê¸õ¥X¨Ó ¥L·|ºCºC¸õ  ·íµM¤]¥i¥H¥Îwait¨Óµ¥
¤]´N¬O¤§«e»¡¨ìªºª¬ªp ¥Îtag³v¨B§äªº¤è¦¡,³oºØ¤À¸Ñ¨BÆJ¥i¥HºCºC§PÂ_¬O§_¤¸¯À¦³¥X²{¤F ¦AÄ~Äò¤U¤@¨Bªº§PÂ_

3
¦L¶H¥i¥H ¦ý¤£«Øij ©È¦h­Óµøµ¡title­«½Æ ¬Ý­Ó®×¨Ï¥Î  
¤U­±¬O§Ú¬d¨ìªº¸ê®Æ
»yªk¦n¹³¬O driver.SwitchToWindowByTitle "Title¦WºÙ"     ¤£¹L§Ú¨S¹ê´ú¹L
https://stackoverflow.com/questions/52397268/how-do-i-switch-focus-to-a-new-window-using-selenium-vba
(¥i¥H¤UgoogleÃöÁä¦r vba selenium SwitchToNextWindow )§ä¬ÛÃö¸ê®Æ
³q±`§ÚÁÙ¬O«Øij¥Îdriver.SwitchToNextWindow¸õÂà
¸õ¹L¥h¦pªG¤£­n¤F,¤]ÁÙ¬O­nÁÙ­n¥Îdriver.SwitchToPreviousWindow¸õ¦^¨Ó

TOP

        ÀR«ä¦Û¦b : °µ¦n¨Æ¤£¯à¤Ö§Ú¤@¤H¡A°µÃa¨Æ¤£¯à¦h§Ú¤@¤H¡C
ªð¦^¦Cªí ¤W¤@¥DÃD