i follow the tutorial on youtube (Configurando Ambiente de Desenvolvimento RPA Java com BotCity - YouTube) but the firstBot it’s not finding the Search “button”
Search button on linkedln:
i called it Find after a few tentatives.
here’s my code:
package dev.botcity.main;
import dev.botcity.framework.bot.DesktopBot;
public class FirstBot extends DesktopBot
{
// Configurando Ambiente de Desenvolvimento RPA Java com BotCity - YouTube
public FirstBot() {
try {
setResourceClassLoader(this.getClass().getClassLoader());
load();
} catch(Exception e) {
e.printStackTrace();
}
}
private void notFound(String label) {
System.out.println("Nao foi possivel encontrar: "+label);
}
private void load() {
try {
addImage("Find", "./src/resources/Find.png");
} catch(Exception e) {
e.printStackTrace();
}
}
public void action() {
try {
//exec("C:\\Program Files\\Fortinet\\FortiClient\\FortiClient.exe");
// JavascriptCodes js = new JavascriptCodes();
// String html = js.getElementAsString("html");
browse("https://www.linkedin.com/feed/");
if(!find( "Find", 1.0, 20000)) { notFound("Find"); return;}
wait(2000);
click();
paste("BotCity RPA");
System.out.println("a");
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new FirstBot().action();
}
}
1 Like
Hi @pedrojonassm ,
To investigate this issue I recommmend you to enable the debug mode. Add enableDebug() in your constructor as follows:
public FirstBot() {
enableDebug();
try {
setResourceClassLoader(this.getClass().getClassLoader());
load();
} catch(Exception e) {
e.printStackTrace();
}
}
After that, create a “debug” folder on your project root folder and run your bot.
Everytime an UI element is not found, an image of the screen and the target UI element is saved in the debug folder so you can check what’s hapenning. The UI element must be on the screen to be found.
1 Like
Ok, i did that and the bot fill the debug folder with print’s and the “Find” image.
There is some print’s when linkedln was loading.
That’s interesting
just saw this error when i select the search image from BotStudio:
Exception in thread “AWT-EventQueue-0” java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
at java.awt.Component.getLocationOnScreen_NoTreeLock(Unknown Source)
at java.awt.Component.getLocationOnScreen(Unknown Source)
at javax.swing.text.JTextComponent$InputMethodRequestsHandler.getTextLocation(Unknown Source)
at sun.awt.im.InputMethodContext.getTextLocation(Unknown Source)
at sun.awt.windows.WInputMethod$1.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Hi @pedrojonassm ,
This exception on Studio is not related to the execution of your bot (since studio is just used to create the bots).
As we discussed outside Discourse, your problem was your setup. Your Windows was set to use zoom of 125%.
To deploy bots we recommend to not use zooms of any kind (Windows, Chrome, etc). Set everything to default 100%.
1 Like