testcontainers-java icon indicating copy to clipboard operation
testcontainers-java copied to clipboard

Selenium docs suggest deprecated `getTestHostIpAddress()` instead of host exposing mechanism

Open GregJohnStewart opened this issue 2 years ago • 9 comments

Trying to get my Selenium WebDriver testcontainer up, I get the following error when I try to get the host's port using getTestHostIpAddress():

Caused by: java.lang.UnsupportedOperationException: getTestHostIpAddress() is only implemented for docker-machine right now

I am running this on Ubuntu 20.04

Any ideas?

GregJohnStewart avatar Feb 20 '22 13:02 GregJohnStewart

Have a look at https://www.testcontainers.org/features/networking/#exposing-host-ports-to-the-container

Here is an example: https://github.com/testcontainers/testcontainers-java/blob/master/examples/selenium-container/src/test/java/SeleniumContainerTest.java

bsideup avatar Feb 20 '22 13:02 bsideup

Thanks, looks like it works. Maybe the documentation should reflect this?

GregJohnStewart avatar Feb 20 '22 14:02 GregJohnStewart

uh? 😅 Wasn't that a link to the documentation?

bsideup avatar Feb 20 '22 14:02 bsideup

lol I meant to the Webdriver docs, they just have you use getTestHostIpAddress()

GregJohnStewart avatar Feb 20 '22 14:02 GregJohnStewart

Ah, great point, thank you! Would you like to contribute a fix? :)

Here is the file: https://github.com/testcontainers/testcontainers-java/blob/master/docs/modules/webdriver_containers.md

bsideup avatar Feb 20 '22 14:02 bsideup

While I'm at it, did we want to add an additional bit on recording? Like the fact recording doesn't seem to happen outside of the following context:

@Container/@Rule
public BrowserWebDriverContainer ...

GregJohnStewart avatar Feb 22 '22 22:02 GregJohnStewart

You are right, currently automatic recording based on failed tests only works in conjunction with the JUnit4 or JUnit5 module. However, you can manually trigger the saving of the recording by calling afterTest(TestDescription description, Optional<Throwable> throwable) on the container object.

I think clarifying this in the docs would be great 👍

kiview avatar Feb 23 '22 13:02 kiview

Thanks! I'll look at getting that in too. Happen to know how to get those parameters in the context of an @AfterEach for example?

GregJohnStewart avatar Feb 28 '22 19:02 GregJohnStewart

It sees like the latest docs do not suggest usage of getTestHostIpAddress() and instead suggest usage of the host exposing mechanism: https://www.testcontainers.org/modules/webdriver_containers/ Screenshot from 2022-08-25 21-39-10 I think this issue can be closed.

aidando73 avatar Aug 25 '22 12:08 aidando73

@REslim30 You are right, thanks for letting us know.

kiview avatar Oct 04 '22 13:10 kiview