imacros FireFox: Cannot replicate this website but

2019-08-20 16:19发布

FF 42.0 / Imacros for FF BUILD=8940826 / 2.8Ghz 8 core Early 2008 MacPro / OSX 10.8.2

PROBLEM: After clicking on the search icon on Spotify's web player, a drawer opens which contains the search field. Enter a search term, and buttons appear below the search field within the drawer. I want to press the first button for top results which is the artist page for the most direct search hit (outlined in green).

http://s27.postimg.org/ga14uslpf/Search_drawer.png

Doing so manually takes you directly to that artist's page. ALL of the recording modes when played back fail to replicate this. Instead of going to the artist page, the recorded button presses bring you to a search results page. Clicking the first result there would be acceptable too, but this button has the same issue. Replaying recorded clicks only reloads the search results page. (outlined in red on results page)

enter image description here

The last few lines (all commented out) represent the recorded button press for the first option (first top results button within search drawer) I tried all available recording modes plus xpath option as far as I was able to figure that out. I have spent a week on this issue now, read well over a hundred pages of info, and I can find no mention anywhere of anyone encountering this behavior, let alone figuring out how to solve it.

MORE than happy to buy a pint and assign a karmic gold star to any good samaritan out there who can lend a hand. I should mention site requires login, but any random info will do and get you on in seconds with no verification. Macro assumes one word artist name with capitalized first letter only.

SET artist Chromeo

URL GOTO=https://play.spotify.com/browse
WAIT SECONDS=3
EVENT TYPE=CLICK SELECTOR="#nav-search" BUTTON=0
WAIT SECONDS=2
FRAME F=1
EVENTS TYPE=KEYPRESS SELECTOR="HTML>BODY>DIV>FORM>INPUT" CHARS={{artist}}
WAIT SECONDS=3

'CLICK X=173 Y=188
'EVENT TYPE=MOUSEUP POINT="(136,180)"
'TAG POS=1 TYPE=A ATTR=DRAGGABLE:true&&DATA-DRAG-TEXT:{{artist}}&&DATA-URI:spotify:artist:*
'TAG POS=1 TYPE=A ATTR=TXT:
'TAG XPATH="(/html/body/div[3]/div[1]/div[1]/ul[1]/li/a)"

Also, if helpful, here is the html for the button as retrieved by firebug (xpath above also via firebug):

<a draggable="true" data-drag-text="Chromeo" data-uri="spotify:artist:2mV8aJphiSHYJf43DxL7Gt">
    </a>

For simplicity, I have extracted this from what is actually a .js script, so if there is some way around this in js, that is more than welcome as well.

1条回答
太酷不给撩
2楼-- · 2019-08-20 17:10

I didn’t check my code because can’t log in this site with "any random info". So try the following suggestion:

SET artist Chromeo
SET selArtist "a[draggable=true][data-drag-text={{artist}}][data-uri^='spotify:artist:']"
EVENT TYPE=CLICK SELECTOR={{selArtist}} BUTTON=0

or this three events instead of CLICK:

TAG POS=1 TYPE=A ATTR=DRAGGABLE:true&&DATA-DRAG-TEXT:{{artist}}&&DATA-URI:spotify:artist:* CONTENT=EVENT:MOUSEOVER 
EVENT TYPE=MOUSEDOWN SELECTOR={{selArtist}} BUTTON=0
EVENT TYPE=MOUSEUP SELECTOR={{selArtist}} BUTTON=0
查看更多
登录 后发表回答