Looking at the "other" html properties on an element in Selenium - vb.net

I'm using Selenium to automate some very basic data entry tasks. Sadly I don't have any influence over the site on which the form is hosted.
I have a number of fields on the form that seem to only differ in fields that I don't know how to make Selenium look at. I find all of the fields on the page and can enter text into them as below:
Dim i As Integer = 0
Dim elements = browser.FindElementsByClassName("form-control")
For Each elemnt In elements
Try
elemnt.SendKeys(i)
Catch
End Try
i += 1
Next
Unfortunately this isn't going to be a long-term solution though, as they might change the order of boxes or similar without notifying me. Is there any way to view the whole of the <input ...> tag?
A selection of the inputs are below:
<input class="form-control ng-valid ng-dirty ng-valid-parse ng-touched" data-ng-model="sQuoteName" kdfapp="Quoting" kdfpage="createDeal" kdfid="dealName" style="">
<input kdfapp="quote" kdfpage="quote" kdfid="amEmail" type="text" class="form-control ng-valid ng-dirty ng-valid-parse ng-touched" id="ciscoEmail" data-ng-model="data.suggestAm" placeholder="Email" style="">
<select name="sQuoteType" data-ng-model="sQuoteType" data-ng-change="changeQuoteType();" kdfapp="Quoting" kdfpage="createDeal" kdfid="selectedBuyingBehalf_xxx" class="ng-pristine ng-untouched ng-valid">
<option value="" class="ng-binding">Select</option>
<option value="2" class="ng-binding">Prime Contractor/Systems Integrator</option>
<option data-ng-show="stiEligible" value="1" class="ng-binding ng-hide">Solution Technology Integrator</option>
<option data-ng-show="partner.partnerBuyMthod == 'DIRECT'" value="3" class="ng-binding" style="">IT Service Provider (Outsourcing Deal)</option>
</select>
The most useful descriptor seems to be kdfid=

Please use GetAttribute method to get the Kdfid.
Sample code:
element.GetAttribute("kdfid")

Related

Selenium (Java) Select tag selection error

<div class="pull-right">
<button type="button" class="btn-excel-select-prd btn btn-sm btn-base">엑셀다운로드</button>
<select id="selectLength" cdgrp="PAGE_LEN" class="form-control input-sm" style="">
<option value="10" title="10개씩 보기">10개씩 보기</option>
<option value="20" title="20개씩 보기">20개씩 보기</option>
<option value="50" title="50개씩 보기" selected="">50개씩 보기</option>
<option value="100" title="100개씩 보기">100개씩 보기</option>
</select>
</div>
enter image description here
I want to choose the 4th option.
However, if I write the code as below, an error "element not interactable: Element is not currently visible and may not be manipulated" appears. How can I solve it?
WebElement selectElement = driver.findElement(By.id("selectLength"));
Select select = new Select(selectElement);
select.selectByIndex(3);
enter image description here

Unable to locate element in Selenium using correct xpath

My AUT have different tabs to test and validate various WebElements, having almost identical properties, present on these tabs.
I need to validate a dropdown searchbox and validate the options listed in the dropdown.
My script can not locate this dropdown searh box, while the xpath work perfectly fine in firebug and can identify the search box.
The error displayed is:
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"//div[#class='btn-group']/select[#id='selectBS']"}
My script is as below:
if(Driver.findElement(By.xpath("//div[#class='btn-group']/select[#id='selectBS']")).isDisplayed());
{
System.out.println(" drop down box is displayed on the View Bill screen");
}
The HTML is as below:
<div class="col-md-5 col-sm-6 col-xs-12">
<div class="row panel panel-default panel-heading">
<div class="col-sm-4 col-xs-12">
<div class="dropdown">
<div class="btn-group">
<select id="selectBS" class="ng-pristine ng-valid ng-touched" ng-change="getBasicSearchSelectedOption()" ng-model="basicSearchSelectedOption" ng-options="option.text for option in basicSearchoptions track by option.index">
<option value="0" selected="selected" label="Search For..">Search For..</option>
<option value="1" label="Invoice Group Number">Invoice Group Number</option>
<option value="2" label="Account Number">Account Number</option>
<option value="3" label="Account Name">Account Name</option>
<option value="4" label="Type">Type</option>
</select>
</div>
</div>
</div>
Please let me know what could be wrong, and why Selenium is not able to locate the element using xpath, while its working fine in xpath.
Also, please let me know if my xpath is not correct.
Check if is present, after that, do some action so the options are visible and check that an option is visible. If these work then it may be an issue checking isDisplayed for elements with type select.

Element not being disabled

I have previously successfully implement this behaviour but for some reason it's not working. I am fairly new to Vue.js and I might be missing something.
I have two radio buttons as such:
<div class="radio">
<label>
<input type="radio" name="loginRadio" id="frmLoginRadio" value="true" v-model="loginRadio" checked>
No, I am new to this site
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="loginRadio" id="frmRegisterRadio" value="false" v-model="loginRadio">
Yes, my password is:
</label>
</div>
They both have a v-model of loginRadio which is initially set to false. When the second radio button is clicked, the disabled input button below should be enabled again.
<input type="password" class="form-control" name="password" :disabled="loginRadio">
However, for some reason, the only thing that is happening is this (when I used Chrome Debug)
<input type="password" class="form-control" name="password" disabled="false">
and the element stays disabled. What am I doing wrong?
You did not use v-bind:for the value attribute of the input buttons
Therefore, loginRadio does not contain boolean values true or false (depending on selection), but strings: "true" and "false"
it should be enough to properly bind the value attribute on both input buttons:
:value="true"
:value="false"

Not able to extract the name of the radio button from DOM using the xpath using selenium

When i pass //input[#type='radio'] in the xpath, i'm able to select all the radio buttons in the list but i am not able to select a particular radio button by it's name.
Name of the radio button is the fourth term in quotes inside the render_selected_term list.
<input type="radio" onclick="Element.show('indicator_radio_term_190');render_selected_term('190','1','275464','AQCB Number')" value="190" name="radio_190"/>
<input type="radio" onclick="Element.show('indicator_radio_term_179');render_selected_term('179','1','275464','AQCB Number (iLink)')" value="179" name="radio_179"/>
<input type="radio" onclick="Element.show('indicator_radio_term_19');render_selected_term('19','1','275464','Acceptance')" value="19" name="radio_19"/>
<input type="radio" onclick="Element.show('indicator_radio_term_148');render_selected_term('148','1','275464','Account (iLink)')" value="148" name="radio_148"/>
<input type="radio" onclick="Element.show('indicator_radio_term_206');render_selected_term('206','1','275464','Additional Non-standard Terms')" value="206" name="radio_206"/>
<input type="radio" onclick="Element.show('indicator_radio_term_220');render_selected_term('220','1','275464','Assigned Contract Manager (iLink)')" value="220" name="radio_220"/>
<input type="radio" onclick="Element.show('indicator_radio_term_12');render_selected_term('12','1','275464','Assignment')" value="12" name="radio_12"/>
<input type="radio" onclick="Element.show('indicator_radio_term_188');render_selected_term('188','1','275464','Authorized Purchasing Entity(ies)')" value="188" name="radio_188"/>
<input type="radio" onclick="Element.show('indicator_radio_term_226');render_selected_term('226','1','275464','Award (iLink)')" value="226" name="radio_226"/>
<input type="radio" onclick="Element.show('indicator_radio_term_196');render_selected_term('196','1','275464','Award Amount')" value="196" name="radio_196"/>
I would suggest you to use css selector in this case and attribute search. Be very careful when you use the following selector. The match you are looking for has to be unique.
Note: I am not sure which match you are looking for. So, I am showing you an example.
[onclick*='148']
Should match <input type="radio" name="radio_148" value="148" onclick="Element.show('indicator_radio_term_148');render_selected_term('148','1','275464','Account (iLink)')"/>
Try this:
<div id="something">
<input type="radio" onclick="Element.show('indicator_radio_term_190');render_selected_term('190','1','275464','AQCB Number')" value="190" name="radio_190"/>
<input type="radio" onclick="Element.show('indicator_radio_term_179');render_selected_term('179','1','275464','AQCB Number (iLink)')" value="179" name="radio_179"/>
IList<IWebElement> inputs = browser.FindElements(By.XPath("//div[#id='something']/input)");
foreach(var element in inputs)
{
if(element.getAttribute("name").Equals("radio_12"))
element.Click();
}

Shopify cart permalinks: check whether product is in-stock/sold out

I have a customised product.liquid template that includes two products in one template, namely: Bikini Top and Bikini Bottom.
The Bikini Bottom is "externally loaded" into the template using its own cart permalink. My question is, when using cart permalinks, how do I check whether the variant is in-stock or sold out and then display a "sold out" notice if needed?
[EDIT] Below is my cart permalink code for reference:
<form action="/cart/add" method="post" class="variantsform">
<label>Select size</label>
<select name="id">
<option value="1189203320">Small</option>
<option value="1189202416">Medium</option>
<option value="1189200892">Large</option>
<option value="1189203928">Extra Large</option>
</select>
<input type="hidden" name="return_to" value="back" />
<input type="submit" value="Add to cart" class="btn variantsadd">
</form>
at same that you load the variant with liquid, you have to check if is available. Variant manual reference
You also can use the product.first_available_variant