I am trying to automate testing forms that selenium would take too long (javascript heavy modern forms), and I want to use xdotool and get window IDs. I see you can call xdotool selectwindow and click it, but then you have to click it each time. I want to tell it "for google chrome windows where the tab title is x, do y"
I got the window ID here:
cchilders@cchilders-Dell-Precision-M3800:~$ xdotool selectwindow 65011713 This is for chrome itself, each tab gets the same value when clicked. So I expected to find that in ps or a window manager, but no:
cchilders@cchilders-Dell-Precision-M3800:~$ wmctrl -l 0x03a00001 0 cchilders-Dell-Precision-M3800 views.py - /home/cchilders/work_projects - Atom 0x03a00048 0 cchilders-Dell-Precision-M3800 pip_freeze_update.py - /home/cchilders/scripts - Atom 0x03a000bc 0 cchilders-Dell-Precision-M3800 urls.py - /home/cchilders/work_projects - Atom nor does ps work:
(clientsite)cchilders@cchilders-Dell-Precision-M3800:~$ ps -alx F UID PID PPID PRI NI VSZ RSS WCHAN STAT TTY TIME COMMAND 4 0 1 0 20 0 185188 5752 ep_pol Ss ? 0:06 /sbin/init splash 1 0 2 0 20 0 0 0 kthrea S ? 0:00 [kthreadd] 1 0 3 2 20 0 0 0 smpboo S ? 0:02 [ksoftirqd/0] 1 0 5 2 0 -20 0 0 worker S< ? 0:00 [kworker/0:0H] 1 0 7 2 20 0 0 0 rcu_gp S ? 1:10 [rcu_sched] 1 0 8 2 20 0 0 0 rcu_gp S ? 0:00 [rcu_bh] ...etc... nowhere does 65011713 show up. Xdotool is a great tool, but the window manipulation expects you to know a lot about the windows, and from what I remember of using it before, the WINDOW COMMANDS section of https://www.semicomplete.com/projects/xdotool/xdotool.xhtml#window_commands has a lot of ways to find a window you know a lot about, but not much in the way of automating getting that window info. How can I determine the window ID (the format xdotool wants) automatically, say by feeding a script the beginning portion of a URL? Thank you
You can look for Google Chrome in the wmtrl:
(scripts)cchilders@cchilders-Dell-Precision-M3800:~/scripts/bash$ wmctrl -l 0x03e00001 0 cchilders-Dell-Precision-M3800 Edit - Stack Overflow - Google Chrome ... and grab the first number separated by space to int:
In [13]: int("0x03e00001", 16) Out[13]: 65011713 The 16 flag in int tells it expect hexadecimal
In [14]: int("0x03e00001") --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-14-96517b980767> in <module>() ----> 1 int("0x03e00001") ValueError: invalid literal for int() with base 10: '0x03e00001' 
65011713is a binary value. The values returned fromwmctrlare hex values. You'll need to convert to have them match (though none of those three do but then I don't seechromein that list at all). Nothing inpsis at all relevant here though. If you can't get individual window IDs for the tabs though (and you may not be able to) then you likely can't target a tab specifically (or necessarily even see the tabs withxdotoolin the first place). (It might be worth looking at the output fromxwininfo -treeto see if you can find what you are looking for there.)