简体   繁体   English

使用loadUrl在下拉框中获取所有选择选项

[英]Using loadUrl to get all select options in a drop down box

I'm trying to store all values from a drop down box into variables within my android application. 我正在尝试将下拉框中的所有值存储到我的android应用程序中的变量中。 I'm trying to get all options from the below into strings in my app; 我正在尝试将以下所有选项放入应用程序的字符串中;

<select name="cardId" id="select_card_no" onfocus="null" onchange="null">
<option value="">Choose card number</option>
<option value="010607655930" >010607655930</option>
<option value="050538806749" >050538806749</option>
<option value="054100790989" >054100790989</option>
</select>

I've been using code like this to intially log through parts of the site; 我一直在使用这样的代码来初始登录网站的各个部分;

public void onPageFinished(WebView view, String url) {
                if(url == "https://oyster.tfl.gov.uk/oyster/entry.do"){             
                    String ausername = "abcde";
                    String apassword = "12345";
                    view.loadUrl("javascript:document.getElementsByName('j_username')[0].value = '"+ausername+"'");
                    view.loadUrl("javascript:document.getElementsByName('j_password')[0].value = '"+apassword+"'");
                    view.loadUrl("javascript:document.forms[0].submit()");
                }

But was wondering how you could possibly get text back from the current Webview state, can you somehow convert loadUrl into a string; 但是想知道如何从当前Webview状态中获取文本,是否可以将loadUrl转换为字符串?

String ddl = view.loadUrl("javascript:document.getElementById('select_card_no')");

Possible duplicate question. 可能重复的问题。 You may want to check out the answer to this one: 您可能要查看此答案:

android - get Text out of webview android-从Webview中获取文本

Also, there might be an overall better solution than using this webview approach you're trying. 此外,可能有比使用您尝试使用的Webview方法更好的整体解决方案。 That url does have a developer api: android - get Text out of webview 该网址确实具有开发人员API: android-从Webview中获取文本

You may want to try and see if you can get waht you need out of that. 您可能想尝试一下,看看能否从中得到满足。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Java计算Selenium WebDriver中选择下拉框中的选项数量? - How to count the number of options in a select drop down box in Selenium WebDriver using Java? 如何使用 Selenium WebDriver java 从下拉列表中获取所有选项 - How to get all the options from drop down using Selenium WebDriver java 从下拉列表中选择,第二个下拉列表中的选项 - Select from a drop down list, options in a second drop down list 如何使用Selenium和Java从下拉框中获取可用选项? - How do I use Selenium and Java to get the options available from a drop down box? Struts 2在下拉菜单中选择框显示值 - Struts 2 Select Box Display Values in Drop Down 我怎样才能 select 下拉菜单中的所有选项 - Selenium Webdriver? - How can I select all the options in a drop down- Selenium Webdriver? Select 基于 excel 使用 selenium Z2567A5EC9705EB71AC2C98403E 驱动程序的数据的多个下拉选项 - Select multiple drop down options based on the data from excel using selenium web driver Selenium - 如何使用 java 获取下拉列表的选项列表? - Selenium - How do I get the the list of options of a drop down list using java? 使用Selenium Webdriver Java时无法获得下拉选项? - Cannot get drop-down options when using Selenium webdriver Java? 如何在Selenium 2中选择/获取下拉选项 - How to select/get drop down option in Selenium 2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM