-
Dec 15th, 2017, 04:33 AM
#1
Thread Starter
New Member
Select value from webbrowser combobox
Hey...
i'm trying to select value from webbrowser combobox using this method :
Dim theother =
(
From X In WebBrowser1.Document.GetElementsByTagName("select").Cast(Of HtmlElement)()
Where X.GetAttribute("name") = "expYear" Select X.GetElementsByTagName("option")
).FirstOrDefault
Dim othitem = (From X In theother.Cast(Of HtmlElement)() Where X.InnerText = "2019").FirstOrDefault
othitem.SetAttribute("selected", CStr(True))
othitem.RaiseEvent("onchange")
but it didn't help in my case it just changed the value but when i click register it says the the combobox value is nothing so is there any alternative method to select or click at my value ?
Thanks for reading !
-
Dec 15th, 2017, 12:29 PM
#2
Re: Select value from webbrowser combobox
Given an html dropdown control below:
Code:
<select aria-label="Month" name="birthday_month" id="month" title="Month" class="_5dba">
<option value="0">Month</option>
<option value="1">Jan</option>
<option value="2">Feb</option>
<option value="3">Mar</option>
<option value="4">Apr</option>
<option value="5">May</option>
<option value="6">Jun</option>
</select>
To select the month of april, you need to set the value using SetAttribute() method.
VB.NET Code:
WebBrowser1.Document.GetElementById("month").SetAttribute("value", "4")
-
Dec 15th, 2017, 05:26 PM
#3
Thread Starter
New Member
Re: Select value from webbrowser combobox
Originally Posted by KGComputers
Given an html dropdown control below:
Code:
<select aria-label="Month" name="birthday_month" id="month" title="Month" class="_5dba">
<option value="0">Month</option>
<option value="1">Jan</option>
<option value="2">Feb</option>
<option value="3">Mar</option>
<option value="4">Apr</option>
<option value="5">May</option>
<option value="6">Jun</option>
</select>
To select the month of april, you need to set the value using SetAttribute() method.
VB.NET Code:
WebBrowser1.Document.GetElementById("month").SetAttribute("value", "4")
i think you didn't get it !
the main problem is SetAttribute it doesn't help in my case , i have to select the value manually , because when i use SetAttribute it works but the website says i didn't enter any value so i need another method like click to select my value got it ?
-
Dec 16th, 2017, 04:32 AM
#4
Re: Select value from webbrowser combobox
Perhaps you can include the url of the website so others can look into it.
- kgc
-
Dec 17th, 2017, 08:16 PM
#5
Thread Starter
New Member
Re: Select value from webbrowser combobox
Originally Posted by KGComputers
Perhaps you can include the url of the website so others can look into it.
- kgc
it will ask them for payment to continue signing up , by the way all what i want an alternative for SetAttribute is that possible using invoke member or any method else ?
-
Dec 17th, 2017, 10:03 PM
#6
Re: Select value from webbrowser combobox
It is quite possible that the problem you are running into is that the owners of the site don't want you to be able to do what you are doing. What is the URL of the site?
My usual boring signature: Nothing
-
Dec 18th, 2017, 06:21 AM
#7
Thread Starter
New Member
Re: Select value from webbrowser combobox
Originally Posted by Shaggy Hiker
It is quite possible that the problem you are running into is that the owners of the site don't want you to be able to do what you are doing. What is the URL of the site?
no it's not possible , i had a similar problem before with textboxes i had to focus after writing my value or it will say the textboxes value = null i tried to do the same with comboboxes after using SetAttribute but it didn't work that's why i'm asking about another method to select the value from that combobox without SetAttribute , i can't provide the url because the interface will be different and it's complicated "you have to change the user agent etc" that's why i didn't provide the url in the thread because it will be kinda useless .
-
Dec 18th, 2017, 10:01 AM
#8
Re: Select value from webbrowser combobox
Ok, let's be more explicit: The field you show looks like a credit card field. That makes me think that what you are trying to do is against the policy of the site, since pretty much NO site would want you to be able to automate the entry of credit card information. Therefore, they may well have taken steps to prevent you from doing what you are trying to do. That's what the URL would show.
My usual boring signature: Nothing
-
Dec 18th, 2017, 10:57 AM
#9
Thread Starter
New Member
Re: Select value from webbrowser combobox
Originally Posted by Shaggy Hiker
That's what the URL would show.
this part of your replay was totally wrong , the other part yeah maybe but not the same as you said , not credit card filed actually , by the way let's back to our point , the main problem now is SetAttribute is there any alternative way else to pick value from webbrowser combobox ?
-
Dec 18th, 2017, 12:32 PM
#10
Re: Select value from webbrowser combobox
No, the main problem is that, if this action is against the policy of the site in question, then it is also against the AUP of this site, which you agreed to when you signed up. Your being unusually coy about what the site is, and suggesting that what you are doing might be something the site doesn't want you to do, is enough to close the thread. If you feel that what you are doing is acceptable to the site in question, then feel free to PM the URL to me.
My usual boring signature: Nothing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|