我刚接触硒。基本上,我想转到数据库并更改日期,然后重新启动服务以模拟Web应用程序中的电子邮件。我有什么办法可以使用Java通过硒完成此操作,例如向用户显示弹出窗口以执行上述操作,然后在弹出窗口上单击“确定”以继续执行?
TIA
答案 0 :(得分:1)
是的。当警报消失时,硒不会执行任何操作,直到确认或关闭警报为止(手动或通过代码执行)。我正在使用几个示例:
public void msg(String string_msg, String string_tit) {
JDialog dialog = new JDialog();
dialog.setAlwaysOnTop(true);
JOptionPane.showMessageDialog(dialog, string_msg, string_tit, JOptionPane.INFORMATION_MESSAGE);
}
public void msg_opt(String string_msg, String string_tit) {
Object[] btn_text = {"Continue"};
JDialog dialog = new JDialog();
dialog.setAlwaysOnTop(true);
JOptionPane.showOptionDialog(dialog, string_msg, string_tit, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_OPTION, null, btn_text, null);
}
public void msg_results(String string, String[] strings) {
JDialog dialog = new JDialog();
dialog.setAlwaysOnTop(true);
dialog.setLocation(700, 800);
JOptionPane.showMessageDialog(dialog, strings, get_results_title(), JOptionPane.INFORMATION_MESSAGE);
}
public void msg_sms_results(String string, String[] strings) {
JDialog dialog = new JDialog();
dialog.setAlwaysOnTop(true);
dialog.setLocation(1100, 880);
JOptionPane.showMessageDialog(dialog, strings, string, JOptionPane.INFORMATION_MESSAGE);
}
public void msg_err(String string_msg, String string_tit) {
final JDialog dialog = new JDialog();
dialog.setAlwaysOnTop(true);
JOptionPane.showMessageDialog(dialog, string_tit, string_msg, JOptionPane.ERROR_MESSAGE, null);
}
甚至可以使用某些UI元素。另一个例子:
public void uvodni_nastaveni() {
JCheckBox b1 = new JCheckBox("Zobrazovat dialogy s výsledky", false);
JCheckBox b2 = new JCheckBox("Archivovat soubor s výsledky", true);
JCheckBox b3 = new JCheckBox("Po dokončení smazat exportní soubory", true);
JDialog dialog = new JDialog();
Box box = Box.createVerticalBox();
box.add(b1);box.add(b2);
if (today_weekday_str() == "MONDAY") {box.add(b3);}
dialog.add(box);
dialog.setAlwaysOnTop(true);
Object[] btn_text = {"Continue"};
int result = JOptionPane.showOptionDialog(dialog, box, "Nastavení testu", JOptionPane.OK_OPTION, JOptionPane.QUESTION_MESSAGE, null, btn_text, null);
if (result == JOptionPane.OK_OPTION) {
if (b1.isSelected() == true) {zobrazovat_vysledky = true;}
else {zobrazovat_vysledky = false;}
if (b2.isSelected() == true) {archivovat_soubor_s_vysledky = true;}
else {archivovat_soubor_s_vysledky = false;}
if (b3.isSelected() == true) {smazat_exporty = true;}
else {smazat_exporty = false;}
}
else {}
}