{"action":"created","issue":{"url":"https://api.github.com/repos/serenity-bdd/serenity-core/issues/742","repository_url":"https://api.github.com/repos/serenity-bdd/serenity-core","labels_url":"https://api.github.com/repos/serenity-bdd/serenity-core/issues/742/labels{/name}","comments_url":"https://api.github.com/repos/serenity-bdd/serenity-core/issues/742/comments","events_url":"https://api.github.com/repos/serenity-bdd/serenity-core/issues/742/events","html_url":"https://github.com/serenity-bdd/serenity-core/issues/742","id":218473600,"number":742,"title":"Getting text of a hidden element","user":{"login":"nbarrett","id":626941,"avatar_url":"https://avatars3.githubusercontent.com/u/626941?v=3","gravatar_id":"","url":"https://api.github.com/users/nbarrett","html_url":"https://github.com/nbarrett","followers_url":"https://api.github.com/users/nbarrett/followers","following_url":"https://api.github.com/users/nbarrett/following{/other_user}","gists_url":"https://api.github.com/users/nbarrett/gists{/gist_id}","starred_url":"https://api.github.com/users/nbarrett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nbarrett/subscriptions","organizations_url":"https://api.github.com/users/nbarrett/orgs","repos_url":"https://api.github.com/users/nbarrett/repos","events_url":"https://api.github.com/users/nbarrett/events{/privacy}","received_events_url":"https://api.github.com/users/nbarrett/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2017-03-31T11:20:26Z","updated_at":"2017-03-31T11:37:21Z","closed_at":null,"body":"For reasons that I won't bore you with, when we run our tests on a Jenkins infra via a Selenium grid some elements do render in a visible way on the page, which means when I try to get the element text, an `ElementShouldBeVisibleException` is thrown. To overcome this, I've ended up crafting the method below, but wondered if there is a more idiomatic way of obtaining hidden element text using Serenity?\r\n\r\n```\r\n    public static String potentiallyHiddenElementText(Target target, Actor actor) {\r\n        WebElementFacade element = target.resolveFor(actor);\r\n        String textValue = element.getTextValue();\r\n        if (textValue.isEmpty()) {\r\n            StepEventBus.getEventBus().clearStepFailures();\r\n            return BrowseTheWeb.as(actor).evaluateJavascript(\"return arguments[0].innerText;\", element).toString().trim();\r\n        } else {\r\n            return textValue;\r\n        }\r\n    }\r\n```"},"comment":{"url":"https://api.github.com/repos/serenity-bdd/serenity-core/issues/comments/290689674","html_url":"https://github.com/serenity-bdd/serenity-core/issues/742#issuecomment-290689674","issue_url":"https://api.github.com/repos/serenity-bdd/serenity-core/issues/742","id":290689674,"user":{"login":"slasva","id":3584395,"avatar_url":"https://avatars2.githubusercontent.com/u/3584395?v=3","gravatar_id":"","url":"https://api.github.com/users/slasva","html_url":"https://github.com/slasva","followers_url":"https://api.github.com/users/slasva/followers","following_url":"https://api.github.com/users/slasva/following{/other_user}","gists_url":"https://api.github.com/users/slasva/gists{/gist_id}","starred_url":"https://api.github.com/users/slasva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slasva/subscriptions","organizations_url":"https://api.github.com/users/slasva/orgs","repos_url":"https://api.github.com/users/slasva/repos","events_url":"https://api.github.com/users/slasva/events{/privacy}","received_events_url":"https://api.github.com/users/slasva/received_events","type":"User","site_admin":false},"created_at":"2017-03-31T11:37:21Z","updated_at":"2017-03-31T11:37:21Z","body":"User should not see invisible text. So and getText() should not return text of invisible element. You can use js (as you do) or .getAttribute(\"innerText\") ) .\r\nhttps://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/WebElement.html#getText-- \r\nGet the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, without any leading or trailing whitespace."}}
{"actor":{"display_login":"slasva"}}