Scrolling inside a form in Watir










0















I am running a test on a web app using Ruby-Watir-Rspec. It is very simple since I'm a beginner.
I open a form and enter the required information, but the "Create" button is not in the visible area, so I get the message:



Failure/Error: @browser.button(class: xxx).click

Watir::Exception::UnknownObjectException:
element located, but timed out after 30 seconds, waiting for #<Watir::Button: located: true; :class=>xxx, :tag_name=>"button"> to be present

Caused by:
# Selenium::WebDriver::Error::ElementNotVisibleError:
# element not interactable


If I scroll while the script is running, it clicks on the button and the test is successful.
I tried scroll.to, wait_until_present, scroll to coordinates, scroll_into_view, none of them worked.
The only way to make it work was to put " @browser.send_keys :tab" several times until it reaches the button at the bottom of the form.



I believe the problem is the button being inside the form which does not take the entire page (behind the form is the map so that part of the page doesn't have the scrolling option)...so is there some way to scroll inside the form? Or do you know some other approach to finding this button? Any hint is appreciated.

Btw, the page is maximized.



Here is the code snippet, just simple:



it 'should create the place' do
@browser.button(class: xxx).click
end









share|improve this question






















  • It says ElementNotVisibleError, could it be that you disable the button until require fields are filled in the form? And in your test you're not filling all the require fields before you do button click

    – uday
    Nov 15 '18 at 21:07











  • I am filling the form(required fields) in the rest of the test which works fine, this is just the last step in the test - the one that's not working

    – ALB
    Nov 15 '18 at 21:15






  • 1





    Can you provide the (minimal amount of) HTML to reproduce the behavior? Or provide a test link?

    – orde
    Nov 16 '18 at 0:12















0















I am running a test on a web app using Ruby-Watir-Rspec. It is very simple since I'm a beginner.
I open a form and enter the required information, but the "Create" button is not in the visible area, so I get the message:



Failure/Error: @browser.button(class: xxx).click

Watir::Exception::UnknownObjectException:
element located, but timed out after 30 seconds, waiting for #<Watir::Button: located: true; :class=>xxx, :tag_name=>"button"> to be present

Caused by:
# Selenium::WebDriver::Error::ElementNotVisibleError:
# element not interactable


If I scroll while the script is running, it clicks on the button and the test is successful.
I tried scroll.to, wait_until_present, scroll to coordinates, scroll_into_view, none of them worked.
The only way to make it work was to put " @browser.send_keys :tab" several times until it reaches the button at the bottom of the form.



I believe the problem is the button being inside the form which does not take the entire page (behind the form is the map so that part of the page doesn't have the scrolling option)...so is there some way to scroll inside the form? Or do you know some other approach to finding this button? Any hint is appreciated.

Btw, the page is maximized.



Here is the code snippet, just simple:



it 'should create the place' do
@browser.button(class: xxx).click
end









share|improve this question






















  • It says ElementNotVisibleError, could it be that you disable the button until require fields are filled in the form? And in your test you're not filling all the require fields before you do button click

    – uday
    Nov 15 '18 at 21:07











  • I am filling the form(required fields) in the rest of the test which works fine, this is just the last step in the test - the one that's not working

    – ALB
    Nov 15 '18 at 21:15






  • 1





    Can you provide the (minimal amount of) HTML to reproduce the behavior? Or provide a test link?

    – orde
    Nov 16 '18 at 0:12













0












0








0








I am running a test on a web app using Ruby-Watir-Rspec. It is very simple since I'm a beginner.
I open a form and enter the required information, but the "Create" button is not in the visible area, so I get the message:



Failure/Error: @browser.button(class: xxx).click

Watir::Exception::UnknownObjectException:
element located, but timed out after 30 seconds, waiting for #<Watir::Button: located: true; :class=>xxx, :tag_name=>"button"> to be present

Caused by:
# Selenium::WebDriver::Error::ElementNotVisibleError:
# element not interactable


If I scroll while the script is running, it clicks on the button and the test is successful.
I tried scroll.to, wait_until_present, scroll to coordinates, scroll_into_view, none of them worked.
The only way to make it work was to put " @browser.send_keys :tab" several times until it reaches the button at the bottom of the form.



I believe the problem is the button being inside the form which does not take the entire page (behind the form is the map so that part of the page doesn't have the scrolling option)...so is there some way to scroll inside the form? Or do you know some other approach to finding this button? Any hint is appreciated.

Btw, the page is maximized.



Here is the code snippet, just simple:



it 'should create the place' do
@browser.button(class: xxx).click
end









share|improve this question














I am running a test on a web app using Ruby-Watir-Rspec. It is very simple since I'm a beginner.
I open a form and enter the required information, but the "Create" button is not in the visible area, so I get the message:



Failure/Error: @browser.button(class: xxx).click

Watir::Exception::UnknownObjectException:
element located, but timed out after 30 seconds, waiting for #<Watir::Button: located: true; :class=>xxx, :tag_name=>"button"> to be present

Caused by:
# Selenium::WebDriver::Error::ElementNotVisibleError:
# element not interactable


If I scroll while the script is running, it clicks on the button and the test is successful.
I tried scroll.to, wait_until_present, scroll to coordinates, scroll_into_view, none of them worked.
The only way to make it work was to put " @browser.send_keys :tab" several times until it reaches the button at the bottom of the form.



I believe the problem is the button being inside the form which does not take the entire page (behind the form is the map so that part of the page doesn't have the scrolling option)...so is there some way to scroll inside the form? Or do you know some other approach to finding this button? Any hint is appreciated.

Btw, the page is maximized.



Here is the code snippet, just simple:



it 'should create the place' do
@browser.button(class: xxx).click
end






ruby scroll watir






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 20:57









ALBALB

32




32












  • It says ElementNotVisibleError, could it be that you disable the button until require fields are filled in the form? And in your test you're not filling all the require fields before you do button click

    – uday
    Nov 15 '18 at 21:07











  • I am filling the form(required fields) in the rest of the test which works fine, this is just the last step in the test - the one that's not working

    – ALB
    Nov 15 '18 at 21:15






  • 1





    Can you provide the (minimal amount of) HTML to reproduce the behavior? Or provide a test link?

    – orde
    Nov 16 '18 at 0:12

















  • It says ElementNotVisibleError, could it be that you disable the button until require fields are filled in the form? And in your test you're not filling all the require fields before you do button click

    – uday
    Nov 15 '18 at 21:07











  • I am filling the form(required fields) in the rest of the test which works fine, this is just the last step in the test - the one that's not working

    – ALB
    Nov 15 '18 at 21:15






  • 1





    Can you provide the (minimal amount of) HTML to reproduce the behavior? Or provide a test link?

    – orde
    Nov 16 '18 at 0:12
















It says ElementNotVisibleError, could it be that you disable the button until require fields are filled in the form? And in your test you're not filling all the require fields before you do button click

– uday
Nov 15 '18 at 21:07





It says ElementNotVisibleError, could it be that you disable the button until require fields are filled in the form? And in your test you're not filling all the require fields before you do button click

– uday
Nov 15 '18 at 21:07













I am filling the form(required fields) in the rest of the test which works fine, this is just the last step in the test - the one that's not working

– ALB
Nov 15 '18 at 21:15





I am filling the form(required fields) in the rest of the test which works fine, this is just the last step in the test - the one that's not working

– ALB
Nov 15 '18 at 21:15




1




1





Can you provide the (minimal amount of) HTML to reproduce the behavior? Or provide a test link?

– orde
Nov 16 '18 at 0:12





Can you provide the (minimal amount of) HTML to reproduce the behavior? Or provide a test link?

– orde
Nov 16 '18 at 0:12












2 Answers
2






active

oldest

votes


















1














My guess is that this is a custom scrollable element that hides the content with the overflow: hidden style. Elements in the overflow are not considered visible/present. When you manually scroll, you're bringing the element out of the overflow so that it's present.



I've seen a couple of these in the past. Each one needed a different approach for scrolling. Without the exact HTML/CSS, it's hard to say how to scroll the element.



However, if you're not trying to test the scrolling, you could manually fire the click event. This will bypass the visibility requirements:



@browser.button(class: xxx).click!





share|improve this answer























  • I tried to fire the click event and it worked! Thank you so much.

    – ALB
    Nov 16 '18 at 11:33


















0














Try using the Watir Scroll gem: https://github.com/p0deje/watir-scroll and scrolling the element to the center of the viewport: button.scroll.to :center.



You can also submit the form directly @browser.form.submit






share|improve this answer























  • I already tried Watir Scroll gem and button.scroll.to:center, didn't work. The other approach I didn't know for, just tried it, the script was successful but the page sends me "We are sorry, something went wrong" Thank you for you answer!

    – ALB
    Nov 15 '18 at 22:28











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53327794%2fscrolling-inside-a-form-in-watir%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














My guess is that this is a custom scrollable element that hides the content with the overflow: hidden style. Elements in the overflow are not considered visible/present. When you manually scroll, you're bringing the element out of the overflow so that it's present.



I've seen a couple of these in the past. Each one needed a different approach for scrolling. Without the exact HTML/CSS, it's hard to say how to scroll the element.



However, if you're not trying to test the scrolling, you could manually fire the click event. This will bypass the visibility requirements:



@browser.button(class: xxx).click!





share|improve this answer























  • I tried to fire the click event and it worked! Thank you so much.

    – ALB
    Nov 16 '18 at 11:33















1














My guess is that this is a custom scrollable element that hides the content with the overflow: hidden style. Elements in the overflow are not considered visible/present. When you manually scroll, you're bringing the element out of the overflow so that it's present.



I've seen a couple of these in the past. Each one needed a different approach for scrolling. Without the exact HTML/CSS, it's hard to say how to scroll the element.



However, if you're not trying to test the scrolling, you could manually fire the click event. This will bypass the visibility requirements:



@browser.button(class: xxx).click!





share|improve this answer























  • I tried to fire the click event and it worked! Thank you so much.

    – ALB
    Nov 16 '18 at 11:33













1












1








1







My guess is that this is a custom scrollable element that hides the content with the overflow: hidden style. Elements in the overflow are not considered visible/present. When you manually scroll, you're bringing the element out of the overflow so that it's present.



I've seen a couple of these in the past. Each one needed a different approach for scrolling. Without the exact HTML/CSS, it's hard to say how to scroll the element.



However, if you're not trying to test the scrolling, you could manually fire the click event. This will bypass the visibility requirements:



@browser.button(class: xxx).click!





share|improve this answer













My guess is that this is a custom scrollable element that hides the content with the overflow: hidden style. Elements in the overflow are not considered visible/present. When you manually scroll, you're bringing the element out of the overflow so that it's present.



I've seen a couple of these in the past. Each one needed a different approach for scrolling. Without the exact HTML/CSS, it's hard to say how to scroll the element.



However, if you're not trying to test the scrolling, you could manually fire the click event. This will bypass the visibility requirements:



@browser.button(class: xxx).click!






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 16 '18 at 1:05









Justin KoJustin Ko

40.9k56586




40.9k56586












  • I tried to fire the click event and it worked! Thank you so much.

    – ALB
    Nov 16 '18 at 11:33

















  • I tried to fire the click event and it worked! Thank you so much.

    – ALB
    Nov 16 '18 at 11:33
















I tried to fire the click event and it worked! Thank you so much.

– ALB
Nov 16 '18 at 11:33





I tried to fire the click event and it worked! Thank you so much.

– ALB
Nov 16 '18 at 11:33













0














Try using the Watir Scroll gem: https://github.com/p0deje/watir-scroll and scrolling the element to the center of the viewport: button.scroll.to :center.



You can also submit the form directly @browser.form.submit






share|improve this answer























  • I already tried Watir Scroll gem and button.scroll.to:center, didn't work. The other approach I didn't know for, just tried it, the script was successful but the page sends me "We are sorry, something went wrong" Thank you for you answer!

    – ALB
    Nov 15 '18 at 22:28
















0














Try using the Watir Scroll gem: https://github.com/p0deje/watir-scroll and scrolling the element to the center of the viewport: button.scroll.to :center.



You can also submit the form directly @browser.form.submit






share|improve this answer























  • I already tried Watir Scroll gem and button.scroll.to:center, didn't work. The other approach I didn't know for, just tried it, the script was successful but the page sends me "We are sorry, something went wrong" Thank you for you answer!

    – ALB
    Nov 15 '18 at 22:28














0












0








0







Try using the Watir Scroll gem: https://github.com/p0deje/watir-scroll and scrolling the element to the center of the viewport: button.scroll.to :center.



You can also submit the form directly @browser.form.submit






share|improve this answer













Try using the Watir Scroll gem: https://github.com/p0deje/watir-scroll and scrolling the element to the center of the viewport: button.scroll.to :center.



You can also submit the form directly @browser.form.submit







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 15 '18 at 21:24









titusfortnertitusfortner

3,051718




3,051718












  • I already tried Watir Scroll gem and button.scroll.to:center, didn't work. The other approach I didn't know for, just tried it, the script was successful but the page sends me "We are sorry, something went wrong" Thank you for you answer!

    – ALB
    Nov 15 '18 at 22:28


















  • I already tried Watir Scroll gem and button.scroll.to:center, didn't work. The other approach I didn't know for, just tried it, the script was successful but the page sends me "We are sorry, something went wrong" Thank you for you answer!

    – ALB
    Nov 15 '18 at 22:28

















I already tried Watir Scroll gem and button.scroll.to:center, didn't work. The other approach I didn't know for, just tried it, the script was successful but the page sends me "We are sorry, something went wrong" Thank you for you answer!

– ALB
Nov 15 '18 at 22:28






I already tried Watir Scroll gem and button.scroll.to:center, didn't work. The other approach I didn't know for, just tried it, the script was successful but the page sends me "We are sorry, something went wrong" Thank you for you answer!

– ALB
Nov 15 '18 at 22:28


















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53327794%2fscrolling-inside-a-form-in-watir%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

27

Top Tejano songwriter Luis Silva dead of heart attack at 64

Category:Rhetoric