how to click the submit button in the webpage - vb.net

I'm working on my vb.net application to put the textbox and button as i'm using the webbrowser in my form. I have got a problem with getting the element id from the webpage. When I put the text in the textbox and when I click on the form button, I will get an error: Object reference not set to an instance of an object.
Here is the html source:
<button value="1" class="_42ft _4jy0 _11b _4jy3 _4jy1 selected" type="submit">Post</button>
Here is the code I use:
WebBrowser1.Document.GetElementById("_42ft _4jy0 _11b _4jy3 _4jy1 selected").InvokeMember("click")
Do you know how I can click the button in a webpage who have got the class id?

Your button has a class, not an id, but your code is trying to find it by ID. change your button to:
<button value="1" id="_42ft _4jy0 _11b _4jy3 _4jy1 selected" type="submit">Post</button>
or if you want to get it by class, use getElementsByClassName(""), but this returns a collection of all the buttons with that class. That means you have to know if there are more than 1 with the class name. You get the button by its index, so:
var btn = document.getElementsByClassName("_42ft _4jy0 _11b _4jy3 _4jy1 selected");
btn[0].click();
0 is the first one, 1 is the second and so on

Related

Clicking button with selenium doesn't throw exception but the button isn't actually clicking?

I am trying to click a button, which once clicked some text should appear. Selenium is not throwing any errors which means the buttons should have been clicked however the text is not appearing (it works manually).
<button class = "redButton one">
<img src = "images/name.png" class = redImage">
"Name"
</button>
I tried to click the button with the xpath: "//button[contains(text(), 'Name')]". I don't understand why the text is not appearing.
What is the expected text to be displayed after button click event? In order to help with this request, provide the HTML snippet of <button> before & after click event. Since this is working fine manually, did you try adding adequate wait time for the text to display?

Selenium VBA Unable to Click Checkbox

Using Selenium and Chrome, I'm attempting to check a box located within a table. The table contains 2 checkboxes but they act as radio buttons, in that if I click one, the other will uncheck.
I've tried a variety of methods, which include the following:
Const CHECKED_STATE As String = "Ag-icon ag-icon-checkbox-checked"
findElementByClassName("ag-selection-checkbox").fireEvent("CHECKED_STATE")
findElementbyXPath("//span[#class=ag-icon ag-icon-checkbox-checked'])[1]").Click
findElementbyXPath(".//div[#class='ag-body-container']").Click
I'm not sure how to click the checkbox when the HTML code doesn't even have a checkbox type or an Id.
The HTML reads:
<span class="ag-icon-checkbox">
<span class = "ag-icon ag-icon checkbox-checked ag-hidden">
<span class = "ag-icon ag-icon checkbox-unchecked">
<span class = "ag-icon ag-icon checkbox-undeterminate ag-hidden"></span>
When I click on the checkbox, the unchecked and hidden lines of HTML will flip. So I'm guessing it's some sort of event that I have to trigger.
The following, depending on the rest of the html, should work to select the unchecked item and thereby toggle off the other item. It targets the class checkbox-unchecked:
driver.FindElementByCss(".ag-icon-checkbox .checkbox-unchecked").click

Instead of pick-list field how to create radio button in salesforce lightning component

I have created a page with lightening components as shown the below image, I want to change my pick-List field into radio button next to picklist option to choose the appropriate selection, can someone please help to create radio buttons instead of pickList filed
in the component I have used below code
<div class="slds-form-element">
<div class="slds-form-element__control">
<ui:inputSelect label="Race Type"
aura:id="Type"
class="slds-select"
labelClass="slds-form-element__label"
value="{!v.newRace.Race_Type__c}" />
</div>
Maybe something in line with this: (replace v.Name with attribute that contains the name of the race):
<aura:component>
<lightning:radioGroup name="radioGroup"
label="slds-form-element__label"
options="{! v.newRace.Race_Type__c }"
value="{! v.Name}"
type="radio"/>
</aura:component>

Modal: using modal within elements that were loaded via AJAX after document.load()

What happened: I have a page where user has to click on a button and selection is displayed in modal. When they clicked on what ever they wanted div element on the page is updated, via AJAX, which shows what they have selected and has an option "view item".
I have defined that "view item" should open up another modal view which will have all the information on the item, and now, referring to the above paragraph, rather then opening modal view user is being transferred to that page?
Question:
Is their a walk around for modal to be activated on the elements that were loaded after document load stage?
Example code: On initial load user is presented with following code, at this example item was set prior to load:
<div id="dynamic-area">
Item 1
view selection
</div>
<input type="radio" name="selection" id="selection" value="" data-toggle="modal" data-remote="/selection/search/1" />Change selection
When user have picked a different item after clicking on "change selection" #dynamic-area was fully updated with a data that was fetched via AJAX on the selected item.
So lets say, if user have picked item 3, we would have code below:
<div id="dynamic-area">
Item 3
view selection
</div>
<input type="radio" name="selection" id="selection" value="" data-toggle="modal" data-remote="/selection/search/1" />Change selection
Now if user to click on the "view selection", user is being to the page 'selection/view/3' when user should see modal.
After extending this function action worked as it should

Handle button action in a list

I am trying to develop an iphone application using sencha framework .I need to show a list of items in a list.Each cell in the list holds a button also.If the user clicks on a button in a particular index, then a popover needs to be displayer near to the button .I am using the following code to do this
itemTpl : '<div class="div1"><label class = "tag-name-hdr"> {tagnamehdr} </label> <label class = "tag-name-value" style="width:55px;"> value </label> <input type="text" class ="tag-name-text" name="lname" /> <label class = "unit-name" > unit </label> <select class = "unit-name_dropdown" > <option>mg/dr</option> <option>gm/dr</option> <option>m/dr</option> </select> <input type="image" id="popupbtn" class="template_popup_button" src="Images/arrow_more_orange.png" > </div>',
listeners : {
//itemtap : function(list, index, item, e, popupbtn) {
itemtap : function(list, index, item, evt) {
if(evt.getTarget('.template_popup_button')) {
alert(item);
alert(index);
showOverlay(item, evt, index);
}
}
}
Now my issue is that the popover is showing for the selected cell.I need to show the popover near to the clicked button.Is there any way to get the clicked button object to show the overlay/popover near to that.Now I am passing clicked item cell object as parameter to "showOverlay",i need to pass clicked button object
Thanks in advance..
The evt variable holds information about the event. You could check if evt.target is a button (or the button you want to act upon).
Note that if all you want is a single button per cell, you could use the onItemDisclosure config option, that will add a button for you with a handler.