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

Hide elements in dom. #115

Open
alucardu opened this issue May 2, 2018 · 3 comments
Open

Hide elements in dom. #115

alucardu opened this issue May 2, 2018 · 3 comments

Comments

@alucardu
Copy link

alucardu commented May 2, 2018

I have certain elements I don't want to show on my screenshots. Any way to hide them using Chromy?

@dotneet
Copy link
Contributor

dotneet commented May 2, 2018

it is way to do that.

.evaluate(_ => {
  document.querySelector('#target').style.opacity = '0'
})

@alucardu
Copy link
Author

alucardu commented May 2, 2018

That returns a

COMMAND | ReferenceError: document is not defined

Code--

var elementExists = document.getElementsByClassName(".searchbarX div .hidden-lower-xl");

chromy
  .wait(2500)
  .goto(scenario.url)
  
if (elementExists) {
  chromy
    .evaluate(_ => {
      document.querySelector('.searchbarX div .hidden-lower-xl').style.opacity = '0'
    })
}

It looks like it executes the code before the page is loaded.

@dotneet
Copy link
Contributor

dotneet commented May 2, 2018

document can be accessed in evaluate context only.

does this works?

chromy
  .wait(2500)
  .goto(scenario.url)
  .evaluate(_ => {
      var elementExists = document.getElementsByClassName(".searchbarX div .hidden-lower-xl");
      if (elementExists) {
        document.querySelector('.searchbarX div .hidden-lower-xl').style.opacity = '0'
      }
    })
  .end()

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