0

I am new to Selenium and I want to know how the value to the text box gets loaded when there is no value showing in HTML tag :

<input type="text" name="qty" id="qty" maxlength="5" value="" title="Qty" class="quantity-input qty" 

Or is it getting data from jscript?

<script type="text/javascript"> jQuery(document).on('click','.quantity-plus',function(){ var qty = jQuery.trim(jQuery('#qty').val()); if(qty < 99999) { var moq = jQuery('input[name=opinions]:checked').attr('data-moq'); var incrementquantity = jQuery('input[name=opinions]:checked').attr('data-incrementquantity'); var incrementmode = jQuery('input[name=opinions]:checked').attr('data-incrementmode'); var qty = jQuery.trim(jQuery('#qty').val()); jQuery('.moqerror').html(''); if(Number(qty) >= Number(moq) && parseInt((qty-moq)%incrementquantity) == 0) { var newqty = parseFloat( parseFloat(qty) + parseFloat(incrementquantity)); jQuery('#qty').val(newqty); updateEstimatePrice(); } 

1 Answer 1

2

From the script. value attribute is being set by val()

var newqty = parseFloat( parseFloat(qty) + parseFloat(incrementquantity)); jQuery('#qty').val(newqty); 

I am confused as to why you have 'XPath' in the title of the question, which makes me think I am misunderstanding something.

EDIT: Regarding the question of Selenium:

So this seems a bit open ended - but I'll just give you how I would do it:

Prerequistes:

  1. Jasmine testing framework
  2. promises
  3. webdriverjs's control flow using promises
  4. How angular protractor uses promises

Assuming you are ok with with that:

First, setup Selenium with protractor, (which is a big task) and then you could do this (untested):

describe("Checking selectall, ", function() { it("exists,", function() { var qty = element(By.css('input#qty')); expect(browser.isElementPresent(qty)).toEqual(true); it("clicks loads with a value", function() { qty.getAttribute("value").then(function(data) { return console.log("qty.value", data); }); }); }); }); }); 
Sign up to request clarification or add additional context in comments.

1 Comment

ok thanks, so in selenium how do i retrieve value from the textbox, since it shows 50 inside textbox when page is loaded but value is not shown inside the <input> tag

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.