cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Highlighted
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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

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

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

View solution in original post

8 REPLIES 8
Highlighted
Community Hero

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

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

View solution in original post

Highlighted
Occasional Contributor

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

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(((((

Highlighted
Occasional Contributor

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

OMG

)))))

Alt+Left

Highlighted
Community Hero

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

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
Highlighted
Occasional Contributor

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

So in my case the syntaxe is:

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

 

Highlighted
Community Hero

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

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();

 

Highlighted
Senior Member

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

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.

Highlighted
Occasional Contributor

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

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

Sorry, I hope it will help to some body

New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
Let's start July with new challenges!

Create a script to pass custom command-line arguments as a test parameter for the TechCorner tag!

Will you dare to take the challenge?


Top Kudoed Authors