Can't seem to find element by XPATH

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
apathybear7
Posts: 3
Joined: Sun Sep 12, 2021 10:30 pm

Can't seem to find element by XPATH

Post by apathybear7 » Sun Sep 12, 2021 10:40 pm

deleted due to stalking mod
Last edited by apathybear7 on Sun Sep 19, 2021 3:01 am, edited 3 times in total.
chivracq
Posts: 9929
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Can't seem to find element by XPATH

Post by chivracq » Mon Sep 13, 2021 5:57 am

apathybear7 wrote:
Sun Sep 12, 2021 10:40 pm
Apologies if this has been asked, I tried searching for it and couldn't seem to find the right result.

I am trying to do something fairly basic by typing text into an input field by XPATH like this:

Code: Select all

TAG XPATH="/html/body/div[3]/form[2]/div[1]/div/div/input" CONTENT="Tom Tester"
However I am getting errors like

Code: Select all

RuntimeError: element  specified by /html/body/div[3]/form[2]/div[1]/div/div/input was not found, line: 3
This is the HTML that I'm trying to insert text into (it's the first element input box within the div) is attached.
INPUT 'to' Source.png

Is there a better way to do this?

(F)CIM for me to read, read my Sig, ah-ah...! :mrgreen:

=> Your Thread has VERY probably nothing specific to the 'iMacros for CR' Sub-Forum, especially if you couldn't read the Forum Rules and mention your FCI, ah-ah...!
=> Mention your FCI for me to move it to the "correct" Sub-Forum if needed... :idea:
(And you probably would have already gotten your Answer/Solution instead of that Reply of mine, if you had taken 1 min to read the Forum Rules, ah-ah...! :P )
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 9929
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Can't seem to find element by XPATH

Post by chivracq » Tue Sep 14, 2021 11:45 am

Alright, not much Follow-up, so I moved the Thread to the 'General' Sub-Forum as it indeed has nothing specific for the 'iMacros for CR' Sub-Forum...

@OP also opened a parallel Thread on SOF:
- imacros: Can't locate the input field

... And I was able to play "little Detective", as this Thread is actually of "better" Qlt than the one on our Forum, and contains more Info, => URL of the Site and some "partial" FCI, (hum "partial FCI" sounds a bit weird, ah-ah...!, as the "F" in "FCI" stands for "Full", re-ah-ah...!), so I will quote that Qt/Thread here, except the Screenshot which is the same...
Thread already got a (-1), (not from me, ah-ah...!, I actually find the Qlt "not too bad" for a Thread/Qt about the 'iMacros' Tag on SOF), probably because of the Screenshot, as Screenshots of Code or Source of a Page are never "very clever", tja...!, (hum, a bit surprising though for a User with 7(+)k Rep on that Site), and for our Forum also... :roll:
imacros: Can't locate the input field
Viewed 13 times
-1

I am trying to locate the input “to” field on this webpage: https://www.reddit.com/message/compose/

I've tried both by XPATH and by TAG and can't seem to locate the first input box.

My current code:

Code: Select all

WAIT SECONDS=2
TAG XPATH="//form[@id='compose-message']/div[1]/div/div/input" CONTENT="Tom Tester"
The error message I get:

Code: Select all

RuntimeError: element  specified by //form[@id='compose-message']/div[@id='spacer']/div[@id='roundfield']/div[@id='roundfield-content']/input was not found, line: 3
A screenshot of the input box im trying to reach, incase the website updates at some point enter image description here

Using

Code: Select all

macos and chrome
Tags: google-chrome imacros

ApathyBear
7,425

=> Alright URL of the Site posted, good...!, even if I "can't" have a look myself as I don't have any 'Reddit' Account, mostly because I've never liked the Site which "doesn't work" since 3 or 4 years in my Default Browser (PM26)...

=> And we have some partial FCI:

Code: Select all

macos and chrome
=> Probable FCI:

Code: Select all

iMacros v10.1.1 for CR, 'Free', CR92/93, macOS.
(... As there is no 'PE' Version on macOS, and therefore also no 'Trial' Version...)

>

I won't "comment" about 'XPATH' that I don't like and never use, and I can't test on the Site anyway, but I would expect this "simple" Statement using the 'TAG POS' Mode to work:

Code: Select all

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:compose-message ATTR=NAME:to CONTENT=Tom<SP>Tester
... Well, if the Form ID is "correct", but the 'FORM' Param can usually be omitted...:

Code: Select all

TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:to CONTENT=Tom<SP>Tester
>

And otherwise, from using v10.1.1 for CR, (=> Importance of mentioning your FCI, grrr...!), => it should also work using the 'EVENT' Mode, if the 'TAG' Mode "really" doesn't want to work ... :idea:
(But the 'EVENT' Mode is rather "slow"...)

>>>

And hum..., mini "Piece of Advice", be "careful" with automating posting/sending PM's on a Forum/Site, like 'Reddit' or any Forum probably, this is the "best Way" to be flagged as (potential) Spammer and to get a Forum Ban, ah-ah...! :P :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 9929
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Can't seem to find element by XPATH

Post by chivracq » Wed Sep 15, 2021 3:54 am

Hum, no Follow-up and I guess "we" won't hear from this User anymore as it looks they went for 'Selenium', from some "other" parallel Thread of theirs...:
- Can't locate this input element selenium

I find this one is a bit of a "LQ" (= Low Qlt) Qt (got a (-1) from me), but surprisingly got 4 (Qlt) Answers, I guess Users in the 'Selenium' Tag on SOF are fighting to get as much Rep as possible, ah-ah...! :P

... And @OP followed up neatly in that Thread, upvoted all Answers and even accepted one... :o
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
apathybear7
Posts: 3
Joined: Sun Sep 12, 2021 10:30 pm

Re: Can't seem to find element by XPATH

Post by apathybear7 » Sun Sep 19, 2021 2:58 am

Ew stop stalking me online. This is borderline harassment.
chivracq
Posts: 9929
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Can't seem to find element by XPATH

Post by chivracq » Sun Sep 19, 2021 4:03 am

apathybear7 wrote:
Sun Sep 19, 2021 2:58 am
Ew stop stalking me online. This is borderline harassment.

Rhoooo...!, nice to see some "Follow-up" afterwards, very good...! :D

But, hum..., I don't "stalk you online", ah-ah...!, I simply follow (and answer) several Tech Forums about iMacros and Web-Automation, not my "Fault" if you ask your same Qt / open parallel Threads on those Forums, tja...! :P
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
apathybear7
Posts: 3
Joined: Sun Sep 12, 2021 10:30 pm

Re: Can't seem to find element by XPATH

Post by apathybear7 » Sun Sep 19, 2021 6:15 pm

I can post anything I like anywhere i'd like online, you don't need to unnecessarily dig into my profile and look at questions that I didn't even ask HERE about selenium. Also downvoting my question on Stackoverflow is petty and shows your lack of professionalism.

The fact that I didn't answer right away doesn't mean I don't care, it means I haven't had the chance to sit down and get to an answer. But given your lack of professionalism, and your unhelpful advice, I give up on this forum and community. imacros should really think twice about training mods before letting them act like a ravenous dog on new members.

Peace, CaptainSpank.
Post Reply