1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
package bots;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Label;
import org.eclipse.wb.swt.SWTResourceManager;
public class GUI_bot {
private static Text text;
private static Text text_1;
private static Text text_2;
private static Text text_3;
private static Label lblNombreCycles;
private static Text Cycles;
private static Text text_4;
private static Text text_5;
/**
* Launch the application.
* @param args
*/
public static void main(String[] args) {
Display display = Display.getDefault();
Shell shell = new Shell();
shell.setSize(450, 280);
shell.setText("SEO Incresator");
text = new Text(shell, SWT.BORDER);
text.setBounds(92, 49, 172, 26);
text_1 = new Text(shell, SWT.BORDER);
text_1.setBounds(92, 93, 172, 26);
text_2 = new Text(shell, SWT.BORDER);
text_2.setBounds(92, 140, 172, 26);
text_3 = new Text(shell, SWT.BORDER);
text_3.setBounds(92, 185, 172, 26);
Button Start = new Button(shell, SWT.NONE);
Start.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
WebDriver driver = new FirefoxDriver();
String URL_1 = text.getText();
String URL_2 = text_1.getText();
String URL_3 = text_2.getText();
String URL_4 = text_3.getText();
String session = text_5.getText();
if (session.equals(""))
session = "1";
int i = 0;
int j = 0;
String stop = Cycles.getText();
if (stop.equals(""))
stop = "12";
while (i < Integer.parseInt(stop)) {
if (!URL_1.equals(""))
driver.get(URL_1);
if (!URL_2.equals(""))
driver.get(URL_2);
if (!URL_3.equals(""))
driver.get(URL_3);
if (!URL_4.equals(""))
driver.get(URL_4);
driver.findElement(By.tagName("p")).click();
i++;
j++;
text_4.setText(Integer.toString(i));
if (j == Integer.parseInt(session)) {
driver.close();
driver = new FirefoxDriver();
j = 0;
}
// shell.update(); shell.validate(); shell.revalidate(); J'ai essayé de "refresh" ici mais rien n'y fait.
}
driver.quit();
}
});
Start.setBounds(299, 196, 90, 30);
Start.setText("Start");
lblNombreCycles = new Label(shell, SWT.NONE);
lblNombreCycles.setBounds(299, 36, 110, 20);
lblNombreCycles.setText("Nombre Cycles");
Cycles = new Text(shell, SWT.BORDER);
Cycles.setBounds(309, 62, 78, 26);
Label lblNewLabel = new Label(shell, SWT.NONE);
lblNewLabel.setBounds(138, 10, 126, 20);
lblNewLabel.setText("Seo Incresator");
Label lblNewLabel_1 = new Label(shell, SWT.NONE);
lblNewLabel_1.setAlignment(SWT.CENTER);
lblNewLabel_1.setBounds(18, 49, 70, 20);
lblNewLabel_1.setText("URL 1");
Label lblUrl = new Label(shell, SWT.NONE);
lblUrl.setText("URL 2");
lblUrl.setAlignment(SWT.CENTER);
lblUrl.setBounds(18, 96, 70, 20);
Label lblUrl_1 = new Label(shell, SWT.NONE);
lblUrl_1.setText("URL 3");
lblUrl_1.setAlignment(SWT.CENTER);
lblUrl_1.setBounds(18, 143, 70, 20);
Label lblUrl_2 = new Label(shell, SWT.NONE);
lblUrl_2.setText("URL 4");
lblUrl_2.setAlignment(SWT.CENTER);
lblUrl_2.setBounds(18, 188, 70, 20);
text_4 = new Text(shell, SWT.BORDER);
text_4.setEditable(false);
text_4.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
text_4.setBounds(381, 7, 41, 23);
Label lblSessionCycles = new Label(shell, SWT.NONE);
lblSessionCycles.setBounds(299, 96, 103, 20);
lblSessionCycles.setText("Session cycles");
text_5 = new Text(shell, SWT.BORDER);
text_5.setBounds(309, 122, 78, 26);
Button btnPrivate = new Button(shell, SWT.CHECK);
btnPrivate.setFont(SWTResourceManager.getFont("Segoe UI", 7, SWT.NORMAL));
btnPrivate.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
}
});
btnPrivate.setBounds(299, 164, 123, 26);
btnPrivate.setText("incognito mode");
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
} |
Partager