Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to controll tabs #11

Closed
honzajde opened this issue Apr 13, 2017 · 5 comments
Closed

Trying to controll tabs #11

honzajde opened this issue Apr 13, 2017 · 5 comments

Comments

@honzajde
Copy link

honzajde commented Apr 13, 2017

Hello, I am trying to follow/use your example to open link in a newly activated tab. However link always open in already existing tab. What I am doing wrong?

	err = remote.SetControlNavigation(true)
	if err != nil {
		panic(err)
	}

	// create new tab
	tab, err := remote.NewTab("https://www.google.com")
	log.Printf("%+v\n", tab)

	// navigate in existing tab
	err = remote.ActivateTab(tab)
	if err != nil {
		panic(err)
	}
	_, err = remote.Navigate("https://www.google.com") // navigates different tab
	if err != nil {
		panic(err)
	}

	err = remote.CloseTab(tab) // closes tab that I openned, ok
	if err != nil {
		panic(err)
	}
@raff
Copy link
Owner

raff commented Apr 14, 2017

A couple of things:

  • SetControlNavigation may not do what you thing it does (and actually doesn't seem to work with devtools just yet)

  • Found a bug in "NewTab" that actually wasn't opening the new page. Should be fixed now.

  • I am not sure is not working in your example. My test application seems to be working as I would expect.

I have added a couple of new options to my test application:

--tab N allows you to select a specific tab (use --tabs to figure out in which order the tabs are returned)

--new always create a new tab and open a new page in it.

Try my test application and see how it works. If you still have problem you should send some more details information (the list of open tabs, what tab you are trying to activate, etc.)

@raff raff closed this as completed Apr 14, 2017
@honzajde
Copy link
Author

honzajde commented Apr 15, 2017

Thank you @raff. I have tried your example and that works. However this still does not do what I expect. I am just trying to open a new tab with google and immediately change it's content to cnn. (It looks quite awkward to get list of Tabs when I just received Tab fro the NewTab method. Besides there is no documentation that restricts the use of the received Tab. Maybe this is just another bug... I hope you get me on this.)

	// create new tab
	tab, err := remote.NewTab("https://www.google.com")
	log.Printf("%v\n", tab)

	// activate created tab 
	err = remote.ActivateTab(tab)
	if err != nil {
		panic(err)
	}

	// navigate created tab - navigates wrong tab
	_, err = remote.Navigate("https://www.cnn.com")
	if err != nil {
		panic(err)
	}

@raff
Copy link
Owner

raff commented Apr 17, 2017

Ok, I think I know what's going on.

It looks like when switching between tabs I also needs to connect to the correct websocket (and disconnect from the previous one).

Will try to get it fixed as soon as possible.

@raff raff reopened this Apr 17, 2017
@raff
Copy link
Owner

raff commented Apr 18, 2017

Please update and try again. Let me know if this works and/or if you find any other problem.

@honzajde
Copy link
Author

Now it's opening in the same tab as expected. Tested. OK.

@raff raff closed this as completed Apr 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants