Ask a Question

How to?/back browser button(JavaScript/Chrome)

SOLVED
arybalka
Occasional Contributor

How to?/back browser button(JavaScript/Chrome)

Hi every one,

I can not find how to use back browser button.(JavaScript/Chrome)

I am looking for something like:

 

var page = Sys.Browser().Page("*");

page.back()//doesn't exist - just example 

OR

Browsers.Item(btChrome).back()//doesn't exist - just example 

 

Thanks

 

 

8 REPLIES 8
tristaanogre
Esteemed Contributor

Instead of attempting a custom action or looking for a particular method, use the Keys method on the page object and send

 

Aliases.browser.myPage.Keys(~[Left])

I'm not entirely certain but I think this keystroke combination is supported by all browser types.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
arybalka
Occasional Contributor

Thanks Robert,

I tried:

.........

var page = Sys.Browser().Page("*");
page.Keys("[Left]");//Log:Keyboard input. Normal 13:06:06
page.Keys("[Left]");//Log:Keyboard input. Normal 13:06:06
page.Keys("[Left]");//Log:Keyboard input. Normal 13:06:06

 

But I am still on the same page(((((

arybalka
Occasional Contributor

OMG

)))))

Alt+Left

tristaanogre
Esteemed Contributor

Yup... That's what the ~ character is for. 😉


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
arybalka
Occasional Contributor

So in my case the syntaxe is:

var page = Sys.Browser().Page("*");
page.Keys("~[Left]");

 

Hi,

 

Additionally you can call this method:

 

page = Aliases.browser.yourPageObject; //OR page = Sys.Browser().Page("*");
page.window.history.back();

 

as well as:

 

page.window.history.forward();

 

DexBhp
Senior Member

I have a better solution that is probably more what you are looking for,

 

//Navigates to the previous item in the history list.
var pageObj = Aliases.browser.Page("*");
pageObj.contentDocument.Script.eval("history.back()");
Delay(1000);

 

I really don't understand why there isn't a function implemented in test complete to do this natively.

arybalka
Occasional Contributor

Thanks DexBhp, I changed the tool for automation, so I can't confirm your approach.

Sorry, I hope it will help to some body

cancel
Showing results for 
Search instead for 
Did you mean: