8000 Update README.md · seleniumQuery/seleniumQuery@22d5258 · GitHub
[go: up one dir, main page]

Skip to content

Commit 22d5258

Browse files
committed
Update README.md
1 parent d167ecd commit 22d5258

File tree

1 file changed

+92
-19
lines changed

1 file changed

+92
-19
lines changed

README.md

Lines changed: 92 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ public class SeleniumQueryExample {
4343

4444
$(":text[name='q']").val("selenium"); // the keys are actually typed!
4545
$(":button:contains('Google Search')").click();
46-
47-
// Alternatively: $(":text[name='q']").val("selenium").submit();
46+
// Another way: $(":text[name='q']").val("selenium").submit();
4847

4948
// Besides the short syntax and the jQuery behavior you already know,
5049
// other very useful function in seleniumQuery is .waitUntil(),
@@ -103,6 +102,80 @@ $("#tab tr:nth-child(3n+1)").find("/img[@alt='calendar']/preceding::input").val(
103102
```
104103
Find more about them in [seleniumQuery Selectors wiki page.](https://github.com/seleniumQuery/seleniumQuery/wiki/seleniumQuery-Selectors)
105104

105+
###Flexible WebDriver builder system
106+
107+
How to setup the `WebDriver`? Simply use our builder. The driver will be instantiated only at the first use.
108+
109+
#####Firefox
110+
111+
```java
112+
$.driver().useFirefox(); // Will set up firefox as driver
113+
114+
$.url("http://seleniumquery.github.io"); // the driver will be instantiated when this executes
115+
```
116+
117+
#####Firefox driver with disabled JavaScript
118+
119+
Want `FirefoxDriver` without JavaScript? Just:
120+
```java
121+
$.driver().useFirefox().withoutJavaScript(); // when started, Firefox will have JS OFF
122+
```
123+
124+
#####Chrome, InternetExplorer, PhantomJS drivers
125+
126+
All you have to do is download [their executables](https://github.com/seleniumQuery/seleniumQuery-demos/tree/master/src/main/resources) before. Setting them up in seleniumQuery is all too easy:
127+
128+
```java
129+
// Using Chrome
130+
$.driver().useChrome(); // will look for chromedriver(.exe) to you, including the classpath!
131+
// Or if you want to set the path yourself
132+
$.driver().useChrome().withPathToChromeDriver("path/to/chromedriver.exe")
133+
134+
// InternetExplorerDriver
135+
$.driver().useInternetExplorer(); // we search IEDriverServer.exe for you
136+
// Or you set the path yourself
137+
$.driver().useInternetExplorer().withPathToIEDriverServerExe("C:\\IEDriverServer.exe");
138+
139+
// PhantomJS
140+
$.driver().usePhantomJS(); // again, we'll find phantomjs[.exe] to you
141+
// Or you may set the path yourself
142+
$.driver().usePhantomJS().withPathToPhantomJS("path/to/phantomjs.exe");
143+
````
144+
145+
#####HtmlUnit
146+
147+
So many ways to set up `HtmlUnitDriver`... If only there was a simple way. Oh, wait:
148+
149+
```java
150+
// HtmlUnit default (Chrome/JavaScript ON)
151+
$.driver().useHtmlUnit();
152+
// Want disabled JavaScript, just call .withoutJavaScript()
153+
$.driver().useHtmlUnit().withoutJavaScript();
154+
155+
// HtmlUnit emulating Chrome
156+
$.driver().useHtmlUnit().emulatingChrome();
157+
$.driver().useHtmlUnit().emulatingChrome().withoutJavaScript();
158+
// HtmlUnit emulating Firefox
159+
$.driver().useHtmlUnit().emulatingFirefox(); // could disable JS here as well
160+
// And IE
161+
$.driver().useHtmlUnit().emulatingInternetExplorer11(); // JS is disableable as well
162+
$.driver().useHtmlUnit().emulatingInternetExplorer8(); // JS is disableable as well
163+
$.driver().useHtmlUnit().emulatingInternetExplorer9(); // JS is disableable as well
164+
$.driver().useHtmlUnit().emulatingInternetExplorer(); // will pick latest IE
165+
````
166+
167+
####But there is more
168+
169+
Explore the auto-complete. There are additional options to every browser, such as `.withCapabilities(DesiredCapabilities)` or some specific, such as `.withProfile(FirefoxProfile)` or `.withOptions(ChromeOptions)`.
170+
171+
Finally, if you want to create the `WebDriver` yourself:
172+
173+
```java
174+
WebDriver myDriver = ...;
175+
$.driver().use(myDriver);
176+
```
177+
178+
106179
###Waiting capabilities for improved Ajax testing
107180

108181
Other important feature is the leverage of `WebDriver`'s `FluentWait` capabilities **directly** in the element (no boilerplate code!) through the use of the `.waitUntil()` function:
@@ -126,23 +199,6 @@ And, that's right, the `.is()` function above is your old-time friend that takes
126199
Check out what else `.waitUntil()` can do in the [seleniumQuery API wiki page](https://github.com/seleniumQuery/seleniumQuery/wiki/seleniumQuery-API).
127200

128201

129-
<br>
130-
131-
###Alternate symbols
132-
133-
If the dollar symbol, `$`, gives you the yikes -- we know, it is used for internal class names --, it is important to notice that the `$` symbol in seleniumQuery is not a class name, but a `static` method (and field). Still, if you don't feel like using it, you can resort to `sQ()` or good ol' `jQuery()` and benefit from all the same goodies:
134-
135-
```java
136-
import static io.github.seleniumquery.SeleniumQuery.sQ;
137-
import static io.github.seleniumquery.SeleniumQuery.jQuery;
138-
...
139-
String oldStreet = sQ("input.street").val();
140-
sQ("input.street").val("4th St!");
141-
142-
String oldStreetz = jQuery("input.street").val();
143-
jQuery("input.street").val("5th St!");
144-
```
145-
146202
<br>
147203

148204
##seleniumQuery still is Selenium - with "just" a jQuery interface
@@ -168,6 +224,23 @@ Do as an user would: call `.click()`!
168224

169225
<br>
170226

227+
###Alternate symbols
228+
229+
If the dollar symbol, `$`, gives you the yikes -- we know, it is used for internal class names --, it is important to notice that the `$` symbol in seleniumQuery is not a class name, but a `static` method (and field). Still, if you don't feel like using it, you can resort to `sQ()` or good ol' `jQuery()` and benefit from all the same goodies:
230+
231+
```java
232+
import static io.github.seleniumquery.SeleniumQuery.sQ;
233+
import static io.github.seleniumquery.SeleniumQuery.jQuery;
234+
...
235+
String oldStreet = sQ("input.street").val();
236+
sQ("input.street").val("4th St!");
237+
238+
String oldStreetz = jQuery("input.street").val();
239+
jQuery("input.street").val("5th St!");
240+
```
241+
242+
<br>
243+
171244
#More
172245

173246
Find more on our [wiki](https://github.com/seleniumQuery/seleniumQuery/wiki).

0 commit comments

Comments
 (0)
0