Sorry admin please delete the last 2 unapproved post, this is the revised post.
Hi i have a question, why the 'innerText' and 'textContent' NotWorking to get the value of second 'span', this use with ChromeDriver.
- isnpect00000117014976.PNG (10.84 KiB) Viewed 5244 times
Code: Select all
<div class="price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl" data-purpose="course-price-text"><span class="udlite-sr-only">Current</span><span>Free</span></div>
i tried the possibilities, when using console on inspect element it show the value, but in rufaydium, not value at all.
Code: Select all
aa1 := Page.getElementsByClassName("price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl")[0].getElementsByTagName("span")[1].textContent
aa2 := Page.QuerySelector("[class=""price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl""]")[0].getElementsByTagName("span")[1].innerText
aa21 := Page.QuerySelector("[class=""price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl")[0].getElementsByTagName("span")[1].textContent
aa3 := Page.QuerySelector("[class=""price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl""]")[0].getElementsByTagName("span")[1].innerText
aa4 := Page.getElementsByClassName("price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl")[0].getElementsByTagName("span")[1].innerText
aa5 := Page.CDP.Evaluate("document.getElementsByClassName('price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl')[0].getElementsByTagName('span')[1].textContent;").value
MsgBox, aa2= %aa2% `r`n aa21=%aa21% `r`n aa3= %aa3% `r`n aa4 = %aa4% `r`n aa5= %aa5%
The Second, how to get the value of Page.GetTabs(), THIS also not showing any value. See the Full Code
Code: Select all
#SingleInstance Force
#Include Rufaydium.ahk
#Include CDP.ahk
Chrome := new Rufaydium("chromedriver.exe")
Page := Chrome.NewSession()
Page.CDP.Document()
TestWithIsLoading := 1 ;not working
;TestWithIsLoading := 0 ;working
Loop,
{
if (Clipboard !="" && InStr(Clipboard, "foo")>0 )
{
url_0 := Clipboard
Page.Navigate(url_0)
sleep, 1000
historysaved := url_0 . "`r`n"
FileAppend, url_0. "`r`n", D:\aarun2\AutohotkeyArea\Ruvaydium\Rufaydium-Webdriver-main\myhistory.txt
;ini url dengan isi udemy link.
url_1 := Page.getElementsByClassName("rh_button_wrapper")[0].getElementsByTagName("a")[0].href
Page.getElementsByClassName("rh_button_wrapper")[0].getElementsByTagName("a")[0].click()
;What CODE to make sure not to close the last opened aka url_1 aka Second Tab but the just close the First Tab
;How to Make sure it is not closed the tab with url_1 because of the switchicng time/Loading not always in 1 seconds, how to make it dynamically.
Page.SwitchbyURL(url_0)
MsgBox, % Page.GetTabs() ;<=== this also empty
MsgBox, % Page.GetTabs().value ;<=== this also empty
Sleep 1000
Page.close()
aa1 := Page.getElementsByClassName("price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl")[0].getElementsByTagName("span")[1].textContent
aa2 := Page.QuerySelector("[class=""price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl""]")[0].getElementsByTagName("span")[1].innerText
aa21 := Page.QuerySelector("[class=""price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl")[0].getElementsByTagName("span")[1].textContent
aa3 := Page.QuerySelector("[class=""price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl""]")[0].getElementsByTagName("span")[1].innerText
aa4 := Page.getElementsByClassName("price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl")[0].getElementsByTagName("span")[1].innerText
aa5 := Page.CDP.Evaluate("document.getElementsByClassName('price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl')[0].getElementsByTagName('span')[1].textContent;").value
aa51 := Page.CDP.Evaluate("document.getElementsByClassName('price-text--price-part--2npPm udlite-clp-discount-price udlite-heading-xxl')[0].getElementsByTagName('span')[1].textContent;").value
MsgBox, aa1= %aa1% `r`n aa2= %aa2% `r`n aa21=%aa21% `r`n aa3= %aa3% `r`n aa4 = %aa4% `r`n aa5= %aa5% `r`n aa51= %aa51%
if ( %aa2% == "Free" ){
If TestWithIsLoading ;not working
{
;this forum user said this not working so just make it empty
}
else ;working
{
;Wait until Button "Free" is available
MyButton := ""
While !IsObject(MyButton)
{
sleep, 200
MyButton := Page.findelement(by.linktext,"Add to cart") ;Partial link text
MyButton.click() ;Click on ATC Button
}
}
;Page.getElementsByClassName("udlite-btn udlite-btn-large udlite-btn-brand udlite-heading-md add-to-cart")[0].click()
}else{
MsgBox, 64, Var ab2 Contents, %Clipboard% `r`n`r`nthis will closed on 3 seconds, 5
}
Pause
} else {
Sleep, 2000
}
}
return
^b::
InputBox, asb, Masukkan Url,
if (asb !=""){
if (InStr(asb, "tutorialbar")>0 =){
Page.Navigate(asb)
}
}
return
^m::
Chrome.QuitAllSessions() ; close all session
Chrome.Driver.Exit() ; then exits driver
return
^d::Pause
Return