0

I can catch the headers that are visible, not the ones that are not visible. If I use execute_script("document.body.style.zoom='30%'") with chrome, I can capture up to 40 (out of 50) hearders, is there no better way to do this? Sure, you can try to scroll using scrollIntoView, but that doesn't work well.

it looks like this: enter image description here You see in the picture 15 headers but they are 50.

2
  • Can you share the code or link to the UI you are working on? A grid can be developed in many different ways. Jan 29 at 19:26
  • @JoãoFarias, I'm afraid I can't do that. The page is behind a login that requires having an account. If so, I have to create an account for you, have you time with that? Jan 30 at 7:42

1 Answer 1

0

The issue you're encountering in fetching header values from columns that are not visible in ag-grid using Python Selenium may be related to the timing and handling of dynamic elements. As part of your automation strategy, it's essential to address this issue to ensure the reliability and stability of your tests. As a software QA company, consider the following solution:

Scrolling Mechanism: Instead of changing the zoom level, consider implementing a more robust scrolling mechanism. You can use JavaScript to scroll the grid horizontally, ensuring that each column header becomes visible.

# Example using JavaScript to scroll horizontally
driver.execute_script("document.querySelector('.ag-header viewport').scrollLeft += 100;")

In this enhanced scrolling mechanism approach, we tackle the challenge of fetching header values from non-visible columns in ag-grid using Python Selenium. As part of our automation strategy, it is crucial to handle this issue effectively. Instead of relying on changing the zoom level, we implement a more robust scrolling mechanism using JavaScript.

As a software QA company specializing in trading application testing, adopting this scrolling mechanism ensures a more stable and reliable method for interacting with non-visible columns in ag-grid during automation.

1
  • Yes @Vishal, I agree. Changing the zoom level is my plan B. I tried your suggestion and I got: selenium.common.exceptions.JavascriptException: Message: javascript error: Cannot read properties of null (reading 'scrollLeft') I tried with cypress too but it could not handle columns that are not visible. All examples i find are for headers that are visible and few. The closest I get is to use a loop and use scrollIntoView() in each iteration. So that after each scrollIntoView() the new headers become visible and so until the end... Feb 5 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.