excel input control
This commit is contained in:
@@ -315,9 +315,6 @@ func (l *Luca) BordroTableMaping(frame *rod.Page, b *LucaBordro) ([]BordroPageSc
|
||||
//table := frame.MustElements(".i2")
|
||||
var mainText string
|
||||
for t := 0; t < len(table); t++ {
|
||||
if t == 150 {
|
||||
fmt.Print("asda")
|
||||
}
|
||||
inputElement, err := table[t].Element("input")
|
||||
text, err := table[t].Text()
|
||||
fmt.Print(mainText)
|
||||
@@ -327,13 +324,13 @@ func (l *Luca) BordroTableMaping(frame *rod.Page, b *LucaBordro) ([]BordroPageSc
|
||||
if inputElement != nil {
|
||||
if mainText != "" {
|
||||
fmt.Print(t)
|
||||
inputElement, err := table[t+1].Element("input")
|
||||
if inputElement == nil {
|
||||
elem, err := table[t+1].Element("input")
|
||||
if elem == nil {
|
||||
mainText = ""
|
||||
fmt.Print("Hatalı Text")
|
||||
continue
|
||||
}
|
||||
id, err := inputElement.Attribute("id")
|
||||
id, err := elem.Attribute("id")
|
||||
|
||||
fmt.Print(err)
|
||||
pageScript := BordroPageScript{
|
||||
@@ -347,38 +344,34 @@ func (l *Luca) BordroTableMaping(frame *rod.Page, b *LucaBordro) ([]BordroPageSc
|
||||
mainText = ""
|
||||
}
|
||||
|
||||
}
|
||||
// Satırın özelliklerini al
|
||||
|
||||
// Satırın textini al
|
||||
|
||||
} else {
|
||||
if t <= len(table)-2 {
|
||||
if text != "" {
|
||||
aad, err := table[t+1].Element("input")
|
||||
fmt.Print(err)
|
||||
if aad != nil {
|
||||
aa, err := aad.Attribute("type")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if *aa != "hidden" {
|
||||
id, err := aad.Attribute("id")
|
||||
pageScript := BordroPageScript{
|
||||
Value: text,
|
||||
Index: *id,
|
||||
}
|
||||
scriptIndexArray = append(scriptIndexArray, pageScript)
|
||||
fmt.Print(aad, err, id, aa)
|
||||
}
|
||||
|
||||
// for k, v := range b.Ucretler {
|
||||
// fmt.Print(v, k)
|
||||
// //table'da key--> k i bul,
|
||||
// //takip eden ilk td'deki ilk input'a v'yi yaz
|
||||
// //table'da k'yi bulmazsan ve v de değer varsa hata dön
|
||||
// if strings.Contains(text, k) {
|
||||
// Id := ""
|
||||
// if id != nil {
|
||||
// Id = *id
|
||||
// fmt.Println("ID:", *id)
|
||||
// } else {
|
||||
// Id = ""
|
||||
// }
|
||||
// pageScript := BordroPageScript{
|
||||
// Value: text,
|
||||
// Index: Id,
|
||||
// }
|
||||
}
|
||||
|
||||
// scriptIndexArray = append(scriptIndexArray, pageScript)
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// Sonuçları yazdır ///text boşsa id de boş oluyo
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
fmt.Print(err)
|
||||
}
|
||||
return scriptIndexArray, nil
|
||||
}
|
||||
func (l *Luca) PayrollPageLogin() error {
|
||||
@@ -593,12 +586,17 @@ func (l *Luca) BordroYaz(month, year int, b *LucaBordro, lastItem bool) error {
|
||||
}
|
||||
rsp, err := l.BordroTableMaping(frame3, b)
|
||||
if len(rsp) == 0 {
|
||||
//hata ver
|
||||
return errors.New("Bordro Tablosu Çekilemedi")
|
||||
}
|
||||
fmt.Print(rsp)
|
||||
//rsp den dönden değerler ile matchlencek ve yazılcak
|
||||
for k, v := range b.Ucretler {
|
||||
var elementInsertControl bool = true
|
||||
tt := v.String()
|
||||
fmt.Print(tt)
|
||||
Wait(frame3, 100)
|
||||
for i := 0; i < len(rsp); i++ {
|
||||
|
||||
if k == rsp[i].Value {
|
||||
|
||||
el, err := frame3.Element("#" + rsp[i].Index)
|
||||
@@ -606,10 +604,30 @@ func (l *Luca) BordroYaz(month, year int, b *LucaBordro, lastItem bool) error {
|
||||
return err
|
||||
}
|
||||
err = el.Input(v.String())
|
||||
elementInsertControl = false
|
||||
//el.Eval(`this.dispatchEvent(new KeyboardEvent('keydown', {'key': 'Enter'}))`)
|
||||
break
|
||||
}
|
||||
}
|
||||
if elementInsertControl {
|
||||
if tt != "0" {
|
||||
newBordroPage, err := frame3.Element("body > form > table > tbody > tr.altBar.alt-button-bar > th > table > tbody > tr > td:nth-child(1) > button:nth-child(4)")
|
||||
newBordroPage.WaitLoad()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
newBordroPage.Click(proto.InputMouseButtonLeft, 1)
|
||||
err = WaitLoad(frame3)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ClickItem(frame3, "body > form > table > tbody > tr.altBar.alt-button-bar > th > table > tbody > tr > td:nth-child(1) > button:nth-child(3)", 1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return errors.New(k + " Sütunu Bulunamadı Taslak Hatası, ")
|
||||
}
|
||||
}
|
||||
fmt.Print(v, k)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user