AutoJs-Docs
AutoJs-Docs copied to clipboard
sometime i can find elements sometimes i can't
first of all i mention this i will gladly pay for such a beautiful application but i don't know how and where to buy pro version since it looks like it's only available in china.but i am not sure if i buy this application i will have access to the code to be able to compile it for myself or not.anyway now i want to say what my problem actualy is.
there are some buttons in a website which i am trying to write some autiomation for it.so i need to click on this buttons.first they look blue like this
i need to click on this button
https://i.imgur.com/9ZwQNO7.png
after i click on them,they turn to green or they turn to light blue when they turn to green they look like this and they need another click for verification
https://i.imgur.com/9849DWO.png
when they turn light blue it means task stoped and my code must start looking for new blue darker blue button
https://i.imgur.com/FNxTPqW.png
after i click on confirmation (the green button) the website will open a popup (a new tab in mobile browsers) and it will take me to an instagram page to click on follow button. and after that i need to close that page by pressing back key in android phone and then i will go to the same page with many blue buttons and at the end i have to press on confirm button and the task is finished.so now this is how my code looks like
> auto("fast");
setScreenMetrics(1080, 1920);
console.show();
app.openUrl("url of website");
while (!textContains("0.").exists());
//find untilfind return uiCollection
// bad az foreach uiobject mishe va ina barash sadeghe click ,long click, setText(editable:true),copy(only in inputtype:text),
//cut(only in inputtype:text),paste(input:text),scrollForward,setSelection,scrollBackward(),select()
//collapse(),expand(),show(focus kon),scrollUp(),scrollDown(),scrollLeft(),scrollRight(),children(uicollection mide)
//agar data ba array shoro beshe bayad get1 use koni
//agar data ba aray shoro nashe selector hastesh bayad findOne
//countBlueLeft();
//text = Отмена
sleep(random(3000, 5000));
for (var j = 0; j < 20; j++) {
console.log("j:" + j);
for (var i = 0; i < 21; i++) {
sleep(random(9000, 12000));
click("0.",i);
if (className("android.widget.TextView").text(" Выполнить").findOne().parent().click()) {
id("url_bar").textContains("instagram").waitFor();
sleep(random(4000, 6000))
if (className("android.widget.Button").text("Follow").exists()) {
console.log("here2");
sleep(random(1000, 3000));
(className("android.widget.Button").text("Follow").waitFor() || className("android.widget.Button").text("Following").waitFor());
while (!className("android.widget.Button").text("Follow").findOne().parent().click() || !click("Follow"));
sleep(random(1000, 3000));
back();
sleep(3000);
click("Проверить");
sleep(random(3000, 5000));
} else {
console.log("here3");
sleep(random(1000, 3000));
back();
click("Проверить");
sleep(random(3000, 5000));
}
}
}
}
and now what is my problem you may ask? the problem is sometimes this code can find button sometimes it can't.and i wrote my code in many diffrent type and sometimes it was successful on one device (bigger than android 7) and on the other android device same code is not working and it can't find any element or it stops clicking or many other issues.since i think maybe this issue is happening because of timing and javascript async issues i was trying to use promises in my javascript code but unfortunately it was not supported by this application. but still it doesn't explain why it can not sometimes find elements since i used built in function which this application is offering and made sleep time bigger and bigger so maybe the problem is happening because of that..as you can see in this image
https://i.imgur.com/Y5fvPy2.png
sometimes the green frame is marking buttons which i want sometimes it don't which also makes me think maybe this application has bugs and the problem is not with my javascript code.
i have tried using textContains("x").findOne().click() and descContains("x").findOne().click() and all fo them failed...the thing is the same element in some android has desc and in some other android has text attribute which is odd
Some tips to solve your problems:
- Disable
fastmode by removing the first lineauto('false'). - Write custom filter to match text or desc:
selector().filter(e => e.text() == "x" || e.desc() == "x").findOne()....
As for the Pro version, I plan to distribute it on Google Play to make it available in all regions.