我正试图从中获取"Home"文本
<li class="active"><a href="#">Home</a></li>
Run Code Online (Sandbox Code Playgroud)
我试过了
element = self.browser.find_element_by_class_name('active')
print element.find_element_by_tag_name('a').text
Run Code Online (Sandbox Code Playgroud)
但它返回空字符串.我在这里错过了什么?
试图了解所有RxJava的东西.我在做以下示例:
private Observable<List<String>> query1() {
List<String> urls = new ArrayList<>();
urls.add("1");
urls.add("2");
urls.add("3");
urls.add("4");
return Observable.just(urls);
}
private Observable<List<String>> query2() {
List<String> urls = new ArrayList<>();
urls.add("A");
urls.add("B");
urls.add("C");
urls.add("D");
return Observable.just(urls);
}
Run Code Online (Sandbox Code Playgroud)
然后尝试加入两个列表:
Observable.zip(
query1(),
query2(),
new Func2<List<String>, List<String>, Observable<String>>() {
@Override
public Observable<String> call(List<String> a1, List<String> a2) {
List<String> list = new ArrayList<>();
list.addAll(a1);
list.addAll(a2);
return Observable.from(list);
}
})
.subscribe(new Action1<String>() { // <-- It says, cannot resolve method subscribe
@Override
public void call(String string) {
String text …Run Code Online (Sandbox Code Playgroud) 也许我在这里错过了,但在这里.让我说扩展Button
public class MyButton extends Button {
...
public MyButton(Context context, AttributeSet attrs) {
super(context, attrs);
...
}
}
Run Code Online (Sandbox Code Playgroud)
那么如何在第二种情况下获得对话或活动的实例?
编辑 更多代码以更好地说明我想要做的事情:
public class MyDialog extends Dialog {
private MyButton myButton;
public MyDialog(Context context) {
super(context)
this.setContentView(R.layout.my_dialog);
this.setTitle("My Dialog");
myButton = (MyButton) findViewById(R.id.my_button);
}
}
public class MyButton extends Button implements Command {
private MyActivity myActivity;
public MyButton(Context context, AttributeSet attrs) {
super(context, attrs);
System.out.println(context instanceof ContextThemeWrapper); // TRUE
System.out.println(context instanceof Activity); // FALSE
myActivity = ??? // …Run Code Online (Sandbox Code Playgroud)