webautotester / scenario

JS Library For Puppeteer Actions
MIT License
1 stars 7 forks source link

Use .waitAndClick(selector) instead of .click(selector) #4

Open chenweiLabri opened 6 years ago

chenweiLabri commented 6 years ago

There are many click actions, and after doing one click, the next click can't find the selector because that the website still not be loaded yet. There is a solution that maybe we can use .waitAndClick(selector) instead of .click(selector) So we should add WaitAndClickAction which is similar to ClickAction in this Repository. I am not sure is it ok to solve the problem.

xblanc33 commented 6 years ago

I dont understand what is the error ! Can you give me an example?

Le 6 octobre 2017 17:58:35 GMT+02:00, chenweiLabri notifications@github.com a écrit :

There are many click actions, and after doing one click, the next click can't find the selector because that the website still not be loaded yet. There is a solution that maybe we can use .waitAndClick(selector) instead of .click(selector) So we should add WaitAndClickAction which is similar to ClickAction in this Repository. I am not sure is it ok to solve the problem.

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/webautotester/action_nightmare/issues/4

chenweiLabri commented 6 years ago

This is of themis, the scenario is "addManagerToProject". But sometimes the selector of action we can't find, such as { "type": "ClickAction", "selector": "#admin-page > DIV:nth-child(1) > DIV:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > TABLE:nth-child(2) > TBODY:nth-child(2) > TR:nth-child(1) > TD:nth-child(9) > BUTTON:nth-child(1)" },

and before it we add wait action, { "type":"WaitAction", "ms":1000 }, Then this action can be excuted. So for each click action, we are not sure the selector of next action is loaded in web.

[

{ "type": "GotoAction", "url": "http://localhost:3001/#/admin/projects" },

{ "type": "ClickAction", "selector": "#admin-page-button > IMG:nth-child(1)" },

{ "type": "ClickAction", "selector": "#admin-page > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > UL:nth-child(1) > LI:nth-child(2) > A:nth-child(1) > SPAN:nth-child(2)" },

{ "type":"WaitAction", "ms":1000 },

{ "type": "ClickAction", "selector": "#admin-page > DIV:nth-child(1) > DIV:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > TABLE:nth-child(2) > TBODY:nth-child(2) > TR:nth-child(1) > TD:nth-child(9) > BUTTON:nth-child(1)" },

{ "type":"WaitAction", "ms":1000 },

{ "type": "ClickAction", "selector": "#admin-page > DIV:nth-child(1) > DIV:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > TABLE:nth-child(2) > TBODY:nth-child(2) > TR:nth-child(2) > TD:nth-child(1) > DIV:nth-child(1) > TABLE:nth-child(1) > TBODY:nth-child(2) > TR:nth-child(1) > TD:nth-child(1) > BUTTON:nth-child(1)" },

{ "type":"WaitAction", "ms":1000 },

{ "type": "ClickAction", "selector": "HTML > BODY:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(2) > TABLE:nth-child(1) > TBODY:nth-child(2) > TR:nth-child(1) > TD:nth-child(1) > I:nth-child(1)" },

{ "type":"WaitAction", "ms":1000 },

{ "type": "ClickAction", "selector": "HTML > BODY:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(3) > BUTTON:nth-child(2)" },

{ "type":"WaitAction", "ms":1000 } ]

xblanc33 commented 6 years ago

This is why I added a wait on Wat Look at wat.promyze.com

Le 6 octobre 2017 18:39:10 GMT+02:00, chenweiLabri notifications@github.com a écrit :

This is of themis, the scenario is "addManagerToProject". But sometimes the selector of action we can't find, such as { "type": "ClickAction", "selector": "#admin-page > DIV:nth-child(1) > DIV:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > TABLE:nth-child(2) > TBODY:nth-child(2) > TR:nth-child(1) > TD:nth-child(9) > BUTTON:nth-child(1)" },

and before it we add wait action, { "type":"WaitAction", "ms":1000 }, Then this action can be excuted. So for each click action, we are not sure the selector of next action is loaded in web.

[

{ "type": "GotoAction", "url": "http://localhost:3001/#/admin/projects" },

{ "type": "ClickAction", "selector": "#admin-page-button > IMG:nth-child(1)" },

{ "type": "ClickAction", "selector": "#admin-page > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > UL:nth-child(1) > LI:nth-child(2)

A:nth-child(1) > SPAN:nth-child(2)" },

{ "type":"WaitAction", "ms":1000 },

{ "type": "ClickAction", "selector": "#admin-page > DIV:nth-child(1) > DIV:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > TABLE:nth-child(2) > TBODY:nth-child(2) > TR:nth-child(1) > TD:nth-child(9) > BUTTON:nth-child(1)" },

{ "type":"WaitAction", "ms":1000 },

{ "type": "ClickAction", "selector": "#admin-page > DIV:nth-child(1) > DIV:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > TABLE:nth-child(2) > TBODY:nth-child(2) > TR:nth-child(2) > TD:nth-child(1) > DIV:nth-child(1) > TABLE:nth-child(1) > TBODY:nth-child(2) > TR:nth-child(1) > TD:nth-child(1) > BUTTON:nth-child(1)" },

{ "type":"WaitAction", "ms":1000 },

{ "type": "ClickAction", "selector": "HTML > BODY:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(2) > TABLE:nth-child(1) > TBODY:nth-child(2) > TR:nth-child(1) > TD:nth-child(1) > I:nth-child(1)" },

{ "type":"WaitAction", "ms":1000 },

{ "type": "ClickAction", "selector": "HTML > BODY:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(3) > BUTTON:nth-child(2)" },

{ "type":"WaitAction", "ms":1000 } ]

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/webautotester/action_nightmare/issues/4#issuecomment-334807327

chenweiLabri commented 6 years ago

OK

Xavier Blanc notifications@github.com于2017年10月6日 周五19:51写道:

This is why I added a wait on Wat Look at wat.promyze.com

Le 6 octobre 2017 18:39:10 GMT+02:00, chenweiLabri < notifications@github.com> a écrit :

This is of themis, the scenario is "addManagerToProject". But sometimes the selector of action we can't find, such as { "type": "ClickAction", "selector": "#admin-page > DIV:nth-child(1) > DIV:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > TABLE:nth-child(2) > TBODY:nth-child(2) > TR:nth-child(1) > TD:nth-child(9) > BUTTON:nth-child(1)" },

and before it we add wait action, { "type":"WaitAction", "ms":1000 }, Then this action can be excuted. So for each click action, we are not sure the selector of next action is loaded in web.

[

{ "type": "GotoAction", "url": "http://localhost:3001/#/admin/projects" },

{ "type": "ClickAction", "selector": "#admin-page-button > IMG:nth-child(1)" },

{ "type": "ClickAction", "selector": "#admin-page > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > UL:nth-child(1) > LI:nth-child(2)

A:nth-child(1) > SPAN:nth-child(2)" },

{ "type":"WaitAction", "ms":1000 },

{ "type": "ClickAction", "selector": "#admin-page > DIV:nth-child(1) > DIV:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > TABLE:nth-child(2) > TBODY:nth-child(2) > TR:nth-child(1) > TD:nth-child(9) > BUTTON:nth-child(1)" },

{ "type":"WaitAction", "ms":1000 },

{ "type": "ClickAction", "selector": "#admin-page > DIV:nth-child(1) > DIV:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > TABLE:nth-child(2) > TBODY:nth-child(2) > TR:nth-child(2) > TD:nth-child(1) > DIV:nth-child(1) > TABLE:nth-child(1) > TBODY:nth-child(2) > TR:nth-child(1) > TD:nth-child(1) > BUTTON:nth-child(1)" },

{ "type":"WaitAction", "ms":1000 },

{ "type": "ClickAction", "selector": "HTML > BODY:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(2) > TABLE:nth-child(1) > TBODY:nth-child(2) > TR:nth-child(1) > TD:nth-child(1) > I:nth-child(1)" },

{ "type":"WaitAction", "ms":1000 },

{ "type": "ClickAction", "selector": "HTML > BODY:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(1) > DIV:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(3) > BUTTON:nth-child(2)" },

{ "type":"WaitAction", "ms":1000 } ]

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub:

https://github.com/webautotester/action_nightmare/issues/4#issuecomment-334807327

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/webautotester/action_nightmare/issues/4#issuecomment-334825619, or mute the thread https://github.com/notifications/unsubscribe-auth/AXV6LNzqvq2LPO2key1BASUNyVh0seonks5spmiqgaJpZM4PwsV5 .