Javascript elements - can not click to the right button

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Javascript elements - can not click to the right button

by Iuna on Mon Aug 01, 2016 10:25 am

Windows 2012 Server | Windows 8.1
Firefox 47.0.1
iMacros for Firefox 8.9.7

Website: vk.com

After I had created a post on my wall and decided to edit this post and add a poll, I've found that I can not make it.

If you want to help me, you may prefer to do it by yourself from scratch, or here is the code I'm using:
Code: Select all
TAG POS=1 TYPE=DIV ATTR=CLASS:"post_edit_button fl_r"
TAG POS=1 TYPE=DIV ATTR=CLASS:"post_edit_button fl_r"
TAG POS=1 TYPE=NOBR ATTR=TXT:Attach CONTENT=EVENT:MOUSEOVER
WAIT SECONDS=1.5
TAG POS=1 TYPE=NOBR ATTR=TXT:Other.. CONTENT=EVENT:MOUSEOVER
WAIT SECONDS=1.5
TAG POS=1 TYPE=NOBR ATTR=TXT:Poll CONTENT=EVENT:MOUSEOVER
WAIT SECONDS=1.5
TAG POS=1 TYPE=NOBR ATTR=TXT:Poll

After clicking on last element (TAG POS=1 TYPE=NOBR ATTR=TXT:Poll) JavaScript adds Poll to the form of new post and not to an existing post that I'm editing.

Looks like it happens because of they are using same function with same class, so I've started to look around in order to find the way how to fix it, but I still can't find the way after hours of searching, reading and experimenting.

Clicking to an element by it's XPATH gives an error "RuntimeError: Element DIV is not visible, line 3 (Error code: -921)".
Code: Select all
EVENT TYPE=CLICK XPATH="id('add_media_menu_3')/div/div/div/div[2]" BUTTON=0

I hope there should be an easy way how to manage is, so I ask iMacros community to help me.
I believe this case could be a good example for many situations.
Iuna
 
Posts: 4
Joined: Sun Jul 10, 2016 11:14 am

Re: Javascript elements - can not click to the right button

by iimfun on Tue Aug 02, 2016 6:58 am

Perhaps the way suggested below is not the easiest one, but I just took the function that had been written formerly for other case
Code: Select all
' function to get the last position of the "add_media_type" elements on the 'My Profile' page
SET selectScr "var num = document.querySelectorAll(\"a[class^='add_media_type_']\").length;"
SET !POPUP_ALLOWED {{!URLCURRENT}}
SET openScr "eval('window.open(\\"javascript:'+num+'\\")');"
URL GOTO=javascript:(function(){<SP>{{selectScr}}{{openScr}}<SP>})();
WAIT SECONDS=0.1
SET !EXTRACT_TEST_POPUP NO
TAG POS=1 TYPE=* ATTR=* EXTRACT=TXT
TAB CLOSE
SET posPoll EVAL(({{!EXTRACT}}-1)/8+1)

TAG POS=1 TYPE=DIV ATTR=CLASS:"post_edit_button fl_r"
WAIT SECONDS=1.5
TAG POS={{posPoll}} TYPE=NOBR ATTR=TXT:Attach CONTENT=EVENT:MOUSEOVER
WAIT SECONDS=1.5
TAG POS={{posPoll}} TYPE=NOBR ATTR=TXT:Other.. CONTENT=EVENT:MOUSEOVER
WAIT SECONDS=1.5
TAG POS={{posPoll}} TYPE=NOBR ATTR=TXT:Poll CONTENT=EVENT:MOUSEOVER
WAIT SECONDS=1.5
TAG POS={{posPoll}} TYPE=NOBR ATTR=TXT:Poll
iimfun
 
Posts: 239
Joined: Tue Jul 19, 2016 6:06 am


Return to Data Extraction and Web Screen Scraping

Who is online

Users browsing this forum: No registered users and 2 guests

-->