Help with ecommerce website and pop which says ‘Go to Checkout’ or ‘Continue Shopping’

Hi all.

I am new to all this. On the eCommerce website where I am assuming a pop up box appears which says ‘Go to Checkout’ or ‘Continue Shopping’ I cant get my tests to get pass this.

Is this JavaScript or a simple alert? Which locator do I use and how do I drive the web-driver to get pass this?

Are there answers for the eCommerce website somewhere?

Any help appreciated.

Train Asked on November 27, 2015 in Selenium WebDriver.
Add Comment
  • 5 Answer(s)

    Hi Virender,

    Couldn’t get it working through the CSS. What i did was add a small sleep as you will see from the snippet below and it appears to have done the trick. Some sort of sync issue perhaps. Got lots to learn at the moment. Really appreciate the help so far.

    driver.find_element(:link_text, “All Product”).click
    driver.find_element(:link_text, “iPhone 5″).click
    driver.find_element(:xpath,”//input[@value=’Add To Cart’]”).click

    sleep 10
    driver.find_element(:link_text, “Go to Checkout”).click
    #’expect(driver.find_element(:tag_name, “body”).text).to include(“Checkout”)
    driver.find_element(:xpath,”//input[@value=’Remove’]”).click~

    Train Answered on November 29, 2015.
    Add Comment

    How can we answer you without looking at your website or the HTML code associated with the pop up?

    Professor Answered on November 29, 2015.
    Add Comment

    Hi Virender,

    Apologies. Please find some more info.  When i inspect the element this is the code it points me to. I also attach what I have in my code below where essentially when trying to click on the go to checkout button it is failing. Base URL is http://store.demoqa.com/. Any help greatly appreciated.

    <div class=”popup” style=”display: block;”></div>
    <div id=”fancy_notification” class=”group” style=”display: block; position: fixed; left: 50%; top: 50%; margin-left: -185px; margin-top: -75px;”>
    <div id=”loading_animation”>
    <div id=”fancy_notification_content” class=”group” style=”display: block;”>
    <span>You just added “iPhone 5″ to your cart.</span>
    <br>
    <a class=”go_to_checkout” href=”http://store.demoqa.com/products-page/checkout/”>Go to Checkout</a>
    <a class=”continue_shopping” onclick=”jQuery(“#fancy_notification”).css(“display”, “none”); return false;” href=”#”>Continue Shopping</a>
    </div>
    </div>
    </body>

    25: driver.find_element(:link_text, “iPhone 5”).click                                                                  (this works)
     26: driver.find_element(:xpath,”//input[@value=’Add To Cart’]”).click                        (this works)
     27: driver.find_element(:link_text, “Go to Checkout”).click                                                  ( fails)
    Error
    Unable to locate element: {“method”:”link text”,”selector”:”Go to Checkout”}[remote server] file:///C:/Users/arifi/AppData/Local/Temp/webdrver-profile20151128-11404-1ti3uld/extensions/fxdriver@googlecode.com/components/driver-component.js:10271:in FirefoxDriver.prototype.findElementInternal_'
    [remote server] file:///C:/Users/arifi/AppData/Local/Temp/webdriver-profile20151128-11404-1ti3uld/extensions/fxdriver@googlecode.com/components/driver-component.js:10280:in FirefoxDriver.prototype.findElement’
    [remote server] file:///C:/Users/arifi/AppData/Local/Temp/webdriver-profile20151128-11404-1ti3uld/extensions/fxdriver@googlecode.com/components/command-processor.js:12274:in DelayedCommand.prototype.executeInternal_/h'
    [remote server] file:///C:/Users/arifi/AppData/Local/Temp/webdriver-profile20151128-11404-1ti3uld/extensions/fxdriver@googlecode.com/components/command-processor.js:12279:in DelayedCommand.prototype.executeInternal_’
    [remote server] file:///C:/Users/arifi/AppData/Local/Temp/webdriver-profile20151128-11404-1ti3uld/extensions/fxdriver@googlecode.com/components/command-processor.js:12221:in DelayedCommand.prototype.execute/<'
    c:/agileway/TestWise/vendor/source/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/response.rb:52:in assert_ok’
    c:/agileway/TestWise/vendor/source/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/response.rb:15:in initialize'
    c:/agileway/TestWise/vendor/source/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/http/common.rb:59:in new’
    c:/agileway/TestWise/vendor/source/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/http/common.rb:59:in create_response'
    c:/agileway/TestWise/vendor/source/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/http/default.rb:66:in request’
    c:/agileway/TestWise/vendor/source/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/http/common.rb:40:in call'
    c:/agileway/TestWise/vendor/source/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/bridge.rb:640:in raw_execute’
    c:/agileway/TestWise/vendor/source/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/bridge.rb:618:in execute'
    c:/agileway/TestWise/vendor/source/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/bridge.rb:586:in find_element_by’
    c:/agileway/TestWise/lib/extension/selenium_webdriver_extension.rb:34:in find_element'
    c:/agileway/TestWise/lib/extension/selenium_webdriver_extension.rb:13:in perform_operation’
    c:/agileway/TestWise/lib/extension/selenium_webdriver_extension.rb:27:in find_element'
    C:/testProjects/Practicalwebautomation/selenium-recipes-m-source/selenium-recipes-source/spec/irf_spec.rb:27
    c:/agileway/TestWise/vendor/bundle/ruby/1.8/gems/rspec-core-3.2.2/lib/rspec/core/configuration.rb:1226:in load’
    c:/agileway/TestWise/vendor/bundle/ruby/1.8/gems/rspec-core-3.2.2/lib/rspec/core/configuration.rb:1226:in load_spec_files'
    c:/agileway/TestWise/vendor/bundle/ruby/1.8/gems/rspec-core-3.2.2/lib/rspec/core/configuration.rb:1224:in each’
    c:/agileway/TestWise/vendor/bundle/ruby/1.8/gems/rspec-core-3.2.2/lib/rspec/core/configuration.rb:1224:in load_spec_files'
    c:/agileway/TestWise/vendor/bundle/ruby/1.8/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:97:in setup’
    c:/agileway/TestWise/vendor/bundle/ruby/1.8/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:85:in run'
    c:/agileway/TestWise/vendor/bundle/ruby/1.8/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:70:in run’
    c:/agileway/TestWise/lib/testwise/rspec/rspec_executor.rb:267:in run_spec_via_druby'
    c:/agileway/TestWise/lib/testwise/rspec/rspec_executor.rb:122:in invoke_rspec’
    c:/agileway/TestWise/lib/testwise/rspec/rspec_executor.rb:109:in initialize'
    c:/agileway/TestWise/lib/testwise/rspec/rspec_executor.rb:109:in new’
    c:/agileway/TestWise/lib/testwise/rspec/rspec_executor.rb:109:in invoke_rspec'
    c:/agileway/TestWise/lib/testwise/controllers/testwise_main_controller.rb:314:in run_spec’
    c:/agileway/TestWise/lib/common/base_main_controller.rb:476:in on_run_current_spec_file'
    c:/agileway/TestWise/lib/common/base_main_controller.rb:458:in on_run_spec’
    c:/agileway/TestWise/lib/testwise/views/testwise_main_frame.rb:596:in on_tool_click'
    c:/agileway/TestWise/lib/common/base_main_frame.rb:489:in setup_toolbar_events’
    c:/agileway/TestWise/lib/testwise/app.rb:509:in call'
    c:/agileway/TestWise/lib/testwise/app.rb:509:in process_event’
    c:/agileway/TestWise/lib/testwise/app.rb:509:in `on_run’
    Train Answered on November 29, 2015.
    Add Comment

    Hey,

    Please try the css selector just to verify to click on the chekout link

    #fancy_notification_content > a.go_to_checkout

    Professor Answered on November 29, 2015.
    Add Comment

    Yes I remember that we also faced similar issue. That’s a great find, please mark your question as answered and mark your answer above as the right answer.

    Instead of thread.sleep you would like to put and explicit wait, 

    http://toolsqa.com/selenium-webdriver/implicit-explicit-n-fluent-wait/

    Thanks and keep posting.

    Professor Answered on November 30, 2015.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.