From 97e3d357f5b1afd67e8133f5389bd55ae4fef11a Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Tue, 1 Feb 2011 13:59:17 +0000 Subject: [PATCH 001/114] SimonStewart: Moving the vast bulk of the client-side code to the new java location r11226 --- .../org/openqa/selenium/SearchContext.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/main/java/org/openqa/selenium/SearchContext.java diff --git a/src/main/java/org/openqa/selenium/SearchContext.java b/src/main/java/org/openqa/selenium/SearchContext.java new file mode 100644 index 000000000..b4d97384c --- /dev/null +++ b/src/main/java/org/openqa/selenium/SearchContext.java @@ -0,0 +1,41 @@ +/* +Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package org.openqa.selenium; + +import java.util.List; + +public interface SearchContext { + /** + * Find all elements within the current context using the given mechanism. + * + * @param by The locating mechanism to use + * @return A list of all {@link WebElement}s, or an empty list if nothing matches + * @see org.openqa.selenium.By + */ + List findElements(By by); + + + /** + * Find the first {@link WebElement} using the given method. + * + * @param by The locating mechanism + * @return The first matching element on the current context + * @throws NoSuchElementException If no matching elements are found + */ + WebElement findElement(By by); +} From e5df2e372bced0b2c8743d62ea6991dd0afd01e7 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Wed, 24 Aug 2011 20:17:36 +0000 Subject: [PATCH 002/114] DanielWagnerHall: Bulk reformatting. Some changes may not be perfect; feel free to update if you disagree. r13571 --- .../org/openqa/selenium/SearchContext.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/openqa/selenium/SearchContext.java b/src/main/java/org/openqa/selenium/SearchContext.java index b4d97384c..cb997afc9 100644 --- a/src/main/java/org/openqa/selenium/SearchContext.java +++ b/src/main/java/org/openqa/selenium/SearchContext.java @@ -13,29 +13,29 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ + */ package org.openqa.selenium; import java.util.List; public interface SearchContext { - /** - * Find all elements within the current context using the given mechanism. - * - * @param by The locating mechanism to use - * @return A list of all {@link WebElement}s, or an empty list if nothing matches - * @see org.openqa.selenium.By - */ - List findElements(By by); - - - /** - * Find the first {@link WebElement} using the given method. - * - * @param by The locating mechanism - * @return The first matching element on the current context - * @throws NoSuchElementException If no matching elements are found - */ - WebElement findElement(By by); + /** + * Find all elements within the current context using the given mechanism. + * + * @param by The locating mechanism to use + * @return A list of all {@link WebElement}s, or an empty list if nothing matches + * @see org.openqa.selenium.By + */ + List findElements(By by); + + + /** + * Find the first {@link WebElement} using the given method. + * + * @param by The locating mechanism + * @return The first matching element on the current context + * @throws NoSuchElementException If no matching elements are found + */ + WebElement findElement(By by); } From 93d3fc8996f4db68b109b8549e81289251ef285a Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 10:53:46 +0000 Subject: [PATCH 003/114] SimonStewart: After a code grant, the code is copyright the SFC and the selenium committers. Starting to update the copyright headers r16908 --- src/main/java/org/openqa/selenium/SearchContext.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/SearchContext.java b/src/main/java/org/openqa/selenium/SearchContext.java index cb997afc9..d80cd6710 100644 --- a/src/main/java/org/openqa/selenium/SearchContext.java +++ b/src/main/java/org/openqa/selenium/SearchContext.java @@ -1,6 +1,5 @@ /* Copyright 2007-2009 WebDriver committers -Copyright 2007-2009 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From c405a9a6b4c941020564c4020ae9cef141809f5c Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 14:43:31 +0000 Subject: [PATCH 004/114] SimonStewart: We haven't been just the webdriver project for a long time. We are now the selenium project. No logical changes. r16915 --- src/main/java/org/openqa/selenium/SearchContext.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/SearchContext.java b/src/main/java/org/openqa/selenium/SearchContext.java index d80cd6710..5d3548b81 100644 --- a/src/main/java/org/openqa/selenium/SearchContext.java +++ b/src/main/java/org/openqa/selenium/SearchContext.java @@ -1,5 +1,5 @@ /* -Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Selenium committers Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 6e9b7cf836097cde2a06d3e8b90196b9461a6a20 Mon Sep 17 00:00:00 2001 From: Jason Leyba Date: Sat, 4 Apr 2015 18:34:01 -0700 Subject: [PATCH 005/114] For #401, apply a consistent copyright notice to the java/ tree. Uses a line-comment format rather than block comments for consistency across languages. --- .../org/openqa/selenium/SearchContext.java | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/openqa/selenium/SearchContext.java b/src/main/java/org/openqa/selenium/SearchContext.java index 5d3548b81..5aae99f45 100644 --- a/src/main/java/org/openqa/selenium/SearchContext.java +++ b/src/main/java/org/openqa/selenium/SearchContext.java @@ -1,18 +1,19 @@ -/* -Copyright 2007-2009 Selenium committers - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - */ +// Licensed to the Software Freedom Conservancy (SFC) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The SFC licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. package org.openqa.selenium; @@ -21,7 +22,7 @@ public interface SearchContext { /** * Find all elements within the current context using the given mechanism. - * + * * @param by The locating mechanism to use * @return A list of all {@link WebElement}s, or an empty list if nothing matches * @see org.openqa.selenium.By @@ -31,7 +32,7 @@ public interface SearchContext { /** * Find the first {@link WebElement} using the given method. - * + * * @param by The locating mechanism * @return The first matching element on the current context * @throws NoSuchElementException If no matching elements are found From e13c2ce1cd234b22558d1c34c6f46beaf6ddf282 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Tue, 1 Feb 2011 13:59:17 +0000 Subject: [PATCH 006/114] SimonStewart: Moving the vast bulk of the client-side code to the new java location r11226 --- .../selenium/internal/FindsByClassName.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/org/openqa/selenium/internal/FindsByClassName.java diff --git a/src/main/java/org/openqa/selenium/internal/FindsByClassName.java b/src/main/java/org/openqa/selenium/internal/FindsByClassName.java new file mode 100644 index 000000000..f523df93e --- /dev/null +++ b/src/main/java/org/openqa/selenium/internal/FindsByClassName.java @@ -0,0 +1,27 @@ +/* +Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package org.openqa.selenium.internal; + +import org.openqa.selenium.WebElement; + +import java.util.List; + +public interface FindsByClassName { + WebElement findElementByClassName(String using); + List findElementsByClassName(String using); +} From d1a557bc6f1f3c030076d96ab6d2ad03bcb782cc Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Wed, 24 Aug 2011 19:59:03 +0000 Subject: [PATCH 007/114] DanielWagnerHall: Bulk reformatting. Some changes may not be perfect; feel free to update if you disagree. r13565 --- .../org/openqa/selenium/internal/FindsByClassName.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByClassName.java b/src/main/java/org/openqa/selenium/internal/FindsByClassName.java index f523df93e..62c1e1470 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByClassName.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByClassName.java @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ + */ package org.openqa.selenium.internal; @@ -22,6 +22,7 @@ import java.util.List; public interface FindsByClassName { - WebElement findElementByClassName(String using); - List findElementsByClassName(String using); + WebElement findElementByClassName(String using); + + List findElementsByClassName(String using); } From 244df0a9fa8585e51a255575411c6bad06e6c8ee Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 10:53:46 +0000 Subject: [PATCH 008/114] SimonStewart: After a code grant, the code is copyright the SFC and the selenium committers. Starting to update the copyright headers r16908 --- src/main/java/org/openqa/selenium/internal/FindsByClassName.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByClassName.java b/src/main/java/org/openqa/selenium/internal/FindsByClassName.java index 62c1e1470..060dd92a4 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByClassName.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByClassName.java @@ -1,6 +1,5 @@ /* Copyright 2007-2009 WebDriver committers -Copyright 2007-2009 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 839556054a9a8da118f14e72b37b3391916ecd1d Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 14:43:31 +0000 Subject: [PATCH 009/114] SimonStewart: We haven't been just the webdriver project for a long time. We are now the selenium project. No logical changes. r16915 --- .../java/org/openqa/selenium/internal/FindsByClassName.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByClassName.java b/src/main/java/org/openqa/selenium/internal/FindsByClassName.java index 060dd92a4..14d0864c5 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByClassName.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByClassName.java @@ -1,5 +1,5 @@ /* -Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Selenium committers Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From e14d9c56d6b4f6fac268259c339b8118fe05c5d6 Mon Sep 17 00:00:00 2001 From: Kristian Rosenvold Date: Fri, 11 Jan 2013 22:18:32 +0100 Subject: [PATCH 010/114] KristianRosenvold: Removed windows carriage returns From 880615685c80027e442ecd3f0742f2dbb4cdd50e Mon Sep 17 00:00:00 2001 From: Jason Leyba Date: Sat, 4 Apr 2015 18:34:01 -0700 Subject: [PATCH 011/114] For #401, apply a consistent copyright notice to the java/ tree. Uses a line-comment format rather than block comments for consistency across languages. --- .../selenium/internal/FindsByClassName.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByClassName.java b/src/main/java/org/openqa/selenium/internal/FindsByClassName.java index 14d0864c5..c7f742f0d 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByClassName.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByClassName.java @@ -1,18 +1,19 @@ -/* -Copyright 2007-2009 Selenium committers - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - */ +// Licensed to the Software Freedom Conservancy (SFC) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The SFC licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. package org.openqa.selenium.internal; From 0420245fb45f57e9b257f0371022b6ba30bdb244 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Tue, 1 Feb 2011 13:59:17 +0000 Subject: [PATCH 012/114] SimonStewart: Moving the vast bulk of the client-side code to the new java location r11226 --- .../selenium/internal/FindsByCssSelector.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java diff --git a/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java b/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java new file mode 100644 index 000000000..f86505471 --- /dev/null +++ b/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java @@ -0,0 +1,27 @@ +/* +Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package org.openqa.selenium.internal; + +import org.openqa.selenium.WebElement; + +import java.util.List; + +public interface FindsByCssSelector { + WebElement findElementByCssSelector(String using); + List findElementsByCssSelector(String using); +} From 4f61f72d0d3a0fd3a6c13273cbf731e41c68ea3f Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Wed, 24 Aug 2011 19:59:03 +0000 Subject: [PATCH 013/114] DanielWagnerHall: Bulk reformatting. Some changes may not be perfect; feel free to update if you disagree. r13565 --- .../java/org/openqa/selenium/internal/FindsByCssSelector.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java b/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java index f86505471..7515637ae 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ + */ package org.openqa.selenium.internal; @@ -23,5 +23,6 @@ public interface FindsByCssSelector { WebElement findElementByCssSelector(String using); + List findElementsByCssSelector(String using); } From 4f82dc4fe62ae801b918a23af6057d914b7dd509 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 10:53:46 +0000 Subject: [PATCH 014/114] SimonStewart: After a code grant, the code is copyright the SFC and the selenium committers. Starting to update the copyright headers r16908 --- .../java/org/openqa/selenium/internal/FindsByCssSelector.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java b/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java index 7515637ae..83b36b9c4 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java @@ -1,6 +1,5 @@ /* Copyright 2007-2009 WebDriver committers -Copyright 2007-2009 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 9ca861a3e24b038342c9abade7cfe110b77f17e9 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 14:43:31 +0000 Subject: [PATCH 015/114] SimonStewart: We haven't been just the webdriver project for a long time. We are now the selenium project. No logical changes. r16915 --- .../java/org/openqa/selenium/internal/FindsByCssSelector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java b/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java index 83b36b9c4..79d3267eb 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java @@ -1,5 +1,5 @@ /* -Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Selenium committers Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From ff8bff2c4a13830cfec54fbeacc2d42e5419cf1d Mon Sep 17 00:00:00 2001 From: Kristian Rosenvold Date: Fri, 11 Jan 2013 22:18:32 +0100 Subject: [PATCH 016/114] KristianRosenvold: Removed windows carriage returns From 46ead3c4328d88a5fd46e5e3e46851767928c5f2 Mon Sep 17 00:00:00 2001 From: Jason Leyba Date: Sat, 4 Apr 2015 18:34:01 -0700 Subject: [PATCH 017/114] For #401, apply a consistent copyright notice to the java/ tree. Uses a line-comment format rather than block comments for consistency across languages. --- .../selenium/internal/FindsByCssSelector.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java b/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java index 79d3267eb..5f221c61d 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java @@ -1,18 +1,19 @@ -/* -Copyright 2007-2009 Selenium committers - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - */ +// Licensed to the Software Freedom Conservancy (SFC) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The SFC licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. package org.openqa.selenium.internal; From 894cd62646ce37d7d44ef58cf0b858a24d184aa2 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Tue, 1 Feb 2011 13:59:17 +0000 Subject: [PATCH 018/114] SimonStewart: Moving the vast bulk of the client-side code to the new java location r11226 --- .../openqa/selenium/internal/FindsById.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/org/openqa/selenium/internal/FindsById.java diff --git a/src/main/java/org/openqa/selenium/internal/FindsById.java b/src/main/java/org/openqa/selenium/internal/FindsById.java new file mode 100644 index 000000000..c26aa5daa --- /dev/null +++ b/src/main/java/org/openqa/selenium/internal/FindsById.java @@ -0,0 +1,27 @@ +/* +Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package org.openqa.selenium.internal; + +import org.openqa.selenium.WebElement; + +import java.util.List; + +public interface FindsById { + WebElement findElementById(String using); + List findElementsById(String using); +} From 4b754047dadee1b01be83e852ee2b0e5064ad01e Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Wed, 24 Aug 2011 19:59:03 +0000 Subject: [PATCH 019/114] DanielWagnerHall: Bulk reformatting. Some changes may not be perfect; feel free to update if you disagree. r13565 --- src/main/java/org/openqa/selenium/internal/FindsById.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsById.java b/src/main/java/org/openqa/selenium/internal/FindsById.java index c26aa5daa..b115719ce 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsById.java +++ b/src/main/java/org/openqa/selenium/internal/FindsById.java @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ + */ package org.openqa.selenium.internal; @@ -23,5 +23,6 @@ public interface FindsById { WebElement findElementById(String using); + List findElementsById(String using); } From 1120d3d4e50440c49fd71e3a2f763e823618e034 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 10:53:46 +0000 Subject: [PATCH 020/114] SimonStewart: After a code grant, the code is copyright the SFC and the selenium committers. Starting to update the copyright headers r16908 --- src/main/java/org/openqa/selenium/internal/FindsById.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsById.java b/src/main/java/org/openqa/selenium/internal/FindsById.java index b115719ce..705d4a8d7 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsById.java +++ b/src/main/java/org/openqa/selenium/internal/FindsById.java @@ -1,6 +1,5 @@ /* Copyright 2007-2009 WebDriver committers -Copyright 2007-2009 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 181595c5aa24bcee2b0e8cc6b421e993b65f1ace Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 14:43:31 +0000 Subject: [PATCH 021/114] SimonStewart: We haven't been just the webdriver project for a long time. We are now the selenium project. No logical changes. r16915 --- src/main/java/org/openqa/selenium/internal/FindsById.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsById.java b/src/main/java/org/openqa/selenium/internal/FindsById.java index 705d4a8d7..b4d2e5da5 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsById.java +++ b/src/main/java/org/openqa/selenium/internal/FindsById.java @@ -1,5 +1,5 @@ /* -Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Selenium committers Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 8872b4626f919c60eac7cbf2cdc770e194b27dc8 Mon Sep 17 00:00:00 2001 From: Jason Leyba Date: Sat, 4 Apr 2015 18:34:01 -0700 Subject: [PATCH 022/114] For #401, apply a consistent copyright notice to the java/ tree. Uses a line-comment format rather than block comments for consistency across languages. --- .../openqa/selenium/internal/FindsById.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsById.java b/src/main/java/org/openqa/selenium/internal/FindsById.java index b4d2e5da5..a62e07999 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsById.java +++ b/src/main/java/org/openqa/selenium/internal/FindsById.java @@ -1,18 +1,19 @@ -/* -Copyright 2007-2009 Selenium committers - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - */ +// Licensed to the Software Freedom Conservancy (SFC) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The SFC licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. package org.openqa.selenium.internal; From ab5092a6587970ba9e6f30c344735811d10c9a8c Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Tue, 1 Feb 2011 13:59:17 +0000 Subject: [PATCH 023/114] SimonStewart: Moving the vast bulk of the client-side code to the new java location r11226 --- .../selenium/internal/FindsByLinkText.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/org/openqa/selenium/internal/FindsByLinkText.java diff --git a/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java b/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java new file mode 100644 index 000000000..084760754 --- /dev/null +++ b/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java @@ -0,0 +1,29 @@ +/* +Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package org.openqa.selenium.internal; + +import org.openqa.selenium.WebElement; + +import java.util.List; + +public interface FindsByLinkText { + WebElement findElementByLinkText(String using); + List findElementsByLinkText(String using); + WebElement findElementByPartialLinkText(String using); + List findElementsByPartialLinkText(String using); +} From 1fe9a039de10f3e2623b7bcbfae31fff0da18964 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Wed, 24 Aug 2011 19:59:03 +0000 Subject: [PATCH 024/114] DanielWagnerHall: Bulk reformatting. Some changes may not be perfect; feel free to update if you disagree. r13565 --- .../java/org/openqa/selenium/internal/FindsByLinkText.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java b/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java index 084760754..8da7d574f 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ + */ package org.openqa.selenium.internal; @@ -23,7 +23,10 @@ public interface FindsByLinkText { WebElement findElementByLinkText(String using); + List findElementsByLinkText(String using); + WebElement findElementByPartialLinkText(String using); + List findElementsByPartialLinkText(String using); } From b62de6e957f1decf3592c8789537bab3c40fb9ca Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 10:53:46 +0000 Subject: [PATCH 025/114] SimonStewart: After a code grant, the code is copyright the SFC and the selenium committers. Starting to update the copyright headers r16908 --- src/main/java/org/openqa/selenium/internal/FindsByLinkText.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java b/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java index 8da7d574f..56bf3bb38 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java @@ -1,6 +1,5 @@ /* Copyright 2007-2009 WebDriver committers -Copyright 2007-2009 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From ab1a120b8a571789cd0226bceacd882bb21dafc9 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 14:43:31 +0000 Subject: [PATCH 026/114] SimonStewart: We haven't been just the webdriver project for a long time. We are now the selenium project. No logical changes. r16915 --- src/main/java/org/openqa/selenium/internal/FindsByLinkText.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java b/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java index 56bf3bb38..00ee6080b 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java @@ -1,5 +1,5 @@ /* -Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Selenium committers Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 269b9089a85737ffac9e0fa5e09e19488407f8bc Mon Sep 17 00:00:00 2001 From: Jason Leyba Date: Sat, 4 Apr 2015 18:34:01 -0700 Subject: [PATCH 027/114] For #401, apply a consistent copyright notice to the java/ tree. Uses a line-comment format rather than block comments for consistency across languages. --- .../selenium/internal/FindsByLinkText.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java b/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java index 00ee6080b..f79ecb46f 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java @@ -1,18 +1,19 @@ -/* -Copyright 2007-2009 Selenium committers - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - */ +// Licensed to the Software Freedom Conservancy (SFC) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The SFC licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. package org.openqa.selenium.internal; From 832618208f42ed820cbcd2143cc415c81ae67b77 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Tue, 1 Feb 2011 13:59:17 +0000 Subject: [PATCH 028/114] SimonStewart: Moving the vast bulk of the client-side code to the new java location r11226 --- .../openqa/selenium/internal/FindsByName.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/org/openqa/selenium/internal/FindsByName.java diff --git a/src/main/java/org/openqa/selenium/internal/FindsByName.java b/src/main/java/org/openqa/selenium/internal/FindsByName.java new file mode 100644 index 000000000..b6a1d8d92 --- /dev/null +++ b/src/main/java/org/openqa/selenium/internal/FindsByName.java @@ -0,0 +1,27 @@ +/* +Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package org.openqa.selenium.internal; + +import org.openqa.selenium.WebElement; + +import java.util.List; + +public interface FindsByName { + WebElement findElementByName(String using); + List findElementsByName(String using); +} From 527dda13eeb12ea37a1906c553ae65f6a9e0cec2 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Wed, 24 Aug 2011 19:59:03 +0000 Subject: [PATCH 029/114] DanielWagnerHall: Bulk reformatting. Some changes may not be perfect; feel free to update if you disagree. r13565 --- src/main/java/org/openqa/selenium/internal/FindsByName.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByName.java b/src/main/java/org/openqa/selenium/internal/FindsByName.java index b6a1d8d92..0fef03866 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByName.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByName.java @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ + */ package org.openqa.selenium.internal; @@ -23,5 +23,6 @@ public interface FindsByName { WebElement findElementByName(String using); + List findElementsByName(String using); } From 6b4a5704a00d71f14de00fbd727c4ac490e61902 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 10:53:46 +0000 Subject: [PATCH 030/114] SimonStewart: After a code grant, the code is copyright the SFC and the selenium committers. Starting to update the copyright headers r16908 --- src/main/java/org/openqa/selenium/internal/FindsByName.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByName.java b/src/main/java/org/openqa/selenium/internal/FindsByName.java index 0fef03866..6f432756b 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByName.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByName.java @@ -1,6 +1,5 @@ /* Copyright 2007-2009 WebDriver committers -Copyright 2007-2009 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 57b48f1cd9af19fa2281b88a61fcdf7367eb9b5c Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 14:43:31 +0000 Subject: [PATCH 031/114] SimonStewart: We haven't been just the webdriver project for a long time. We are now the selenium project. No logical changes. r16915 --- src/main/java/org/openqa/selenium/internal/FindsByName.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByName.java b/src/main/java/org/openqa/selenium/internal/FindsByName.java index 6f432756b..38226be5d 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByName.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByName.java @@ -1,5 +1,5 @@ /* -Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Selenium committers Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 3244cc8e686cd470c216922f0d168f0f2614844f Mon Sep 17 00:00:00 2001 From: Jason Leyba Date: Sat, 4 Apr 2015 18:34:01 -0700 Subject: [PATCH 032/114] For #401, apply a consistent copyright notice to the java/ tree. Uses a line-comment format rather than block comments for consistency across languages. --- .../openqa/selenium/internal/FindsByName.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByName.java b/src/main/java/org/openqa/selenium/internal/FindsByName.java index 38226be5d..f4c3f559a 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByName.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByName.java @@ -1,18 +1,19 @@ -/* -Copyright 2007-2009 Selenium committers - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - */ +// Licensed to the Software Freedom Conservancy (SFC) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The SFC licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. package org.openqa.selenium.internal; From 2af82fd4988b7f38002b8c42b58b414ce985d184 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Tue, 1 Feb 2011 13:59:17 +0000 Subject: [PATCH 033/114] SimonStewart: Moving the vast bulk of the client-side code to the new java location r11226 --- .../selenium/internal/FindsByTagName.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/org/openqa/selenium/internal/FindsByTagName.java diff --git a/src/main/java/org/openqa/selenium/internal/FindsByTagName.java b/src/main/java/org/openqa/selenium/internal/FindsByTagName.java new file mode 100644 index 000000000..4559bb6c2 --- /dev/null +++ b/src/main/java/org/openqa/selenium/internal/FindsByTagName.java @@ -0,0 +1,27 @@ +/* +Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package org.openqa.selenium.internal; + +import org.openqa.selenium.WebElement; + +import java.util.List; + +public interface FindsByTagName { + WebElement findElementByTagName(String using); + List findElementsByTagName(String using); +} From 777d798ce252ed42789f432043d1f285a4d54e42 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Wed, 24 Aug 2011 19:59:03 +0000 Subject: [PATCH 034/114] DanielWagnerHall: Bulk reformatting. Some changes may not be perfect; feel free to update if you disagree. r13565 --- .../java/org/openqa/selenium/internal/FindsByTagName.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByTagName.java b/src/main/java/org/openqa/selenium/internal/FindsByTagName.java index 4559bb6c2..1bb2f1c17 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByTagName.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByTagName.java @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ + */ package org.openqa.selenium.internal; @@ -22,6 +22,7 @@ import java.util.List; public interface FindsByTagName { - WebElement findElementByTagName(String using); - List findElementsByTagName(String using); + WebElement findElementByTagName(String using); + + List findElementsByTagName(String using); } From 1a28651c9dcc8261550e38b01b0346daf7526dc1 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 10:53:46 +0000 Subject: [PATCH 035/114] SimonStewart: After a code grant, the code is copyright the SFC and the selenium committers. Starting to update the copyright headers r16908 --- src/main/java/org/openqa/selenium/internal/FindsByTagName.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByTagName.java b/src/main/java/org/openqa/selenium/internal/FindsByTagName.java index 1bb2f1c17..d86072cb4 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByTagName.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByTagName.java @@ -1,6 +1,5 @@ /* Copyright 2007-2009 WebDriver committers -Copyright 2007-2009 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 7d06926a90540f9debc37984fb11dca66610a142 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 14:43:31 +0000 Subject: [PATCH 036/114] SimonStewart: We haven't been just the webdriver project for a long time. We are now the selenium project. No logical changes. r16915 --- src/main/java/org/openqa/selenium/internal/FindsByTagName.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByTagName.java b/src/main/java/org/openqa/selenium/internal/FindsByTagName.java index d86072cb4..5ef915134 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByTagName.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByTagName.java @@ -1,5 +1,5 @@ /* -Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Selenium committers Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From c5829a7604a7edbb2e1864f151f3731b04af3f59 Mon Sep 17 00:00:00 2001 From: Kristian Rosenvold Date: Fri, 11 Jan 2013 22:18:32 +0100 Subject: [PATCH 037/114] KristianRosenvold: Removed windows carriage returns From 7188ee6988ac12273796ef508ec366361267ed37 Mon Sep 17 00:00:00 2001 From: Jason Leyba Date: Sat, 4 Apr 2015 18:34:01 -0700 Subject: [PATCH 038/114] For #401, apply a consistent copyright notice to the java/ tree. Uses a line-comment format rather than block comments for consistency across languages. --- .../selenium/internal/FindsByTagName.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByTagName.java b/src/main/java/org/openqa/selenium/internal/FindsByTagName.java index 5ef915134..5c21fe352 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByTagName.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByTagName.java @@ -1,18 +1,19 @@ -/* -Copyright 2007-2009 Selenium committers - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - */ +// Licensed to the Software Freedom Conservancy (SFC) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The SFC licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. package org.openqa.selenium.internal; From 500e276ebd872009ed22374fad358fc1c94e7fd6 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Tue, 1 Feb 2011 13:59:17 +0000 Subject: [PATCH 039/114] SimonStewart: Moving the vast bulk of the client-side code to the new java location r11226 --- .../selenium/internal/FindsByXPath.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/org/openqa/selenium/internal/FindsByXPath.java diff --git a/src/main/java/org/openqa/selenium/internal/FindsByXPath.java b/src/main/java/org/openqa/selenium/internal/FindsByXPath.java new file mode 100644 index 000000000..bf962ae0d --- /dev/null +++ b/src/main/java/org/openqa/selenium/internal/FindsByXPath.java @@ -0,0 +1,27 @@ +/* +Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package org.openqa.selenium.internal; + +import org.openqa.selenium.WebElement; + +import java.util.List; + +public interface FindsByXPath { + WebElement findElementByXPath(String using); + List findElementsByXPath(String using); +} From f67be62d6e88487b944dc7ef3c70a2a650fedf26 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Wed, 24 Aug 2011 19:59:03 +0000 Subject: [PATCH 040/114] DanielWagnerHall: Bulk reformatting. Some changes may not be perfect; feel free to update if you disagree. r13565 --- src/main/java/org/openqa/selenium/internal/FindsByXPath.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByXPath.java b/src/main/java/org/openqa/selenium/internal/FindsByXPath.java index bf962ae0d..370880e95 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByXPath.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByXPath.java @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ + */ package org.openqa.selenium.internal; @@ -23,5 +23,6 @@ public interface FindsByXPath { WebElement findElementByXPath(String using); + List findElementsByXPath(String using); } From 2d6b2967d3ef2640cbe09621925b14e4ace5b79d Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 10:53:46 +0000 Subject: [PATCH 041/114] SimonStewart: After a code grant, the code is copyright the SFC and the selenium committers. Starting to update the copyright headers r16908 --- src/main/java/org/openqa/selenium/internal/FindsByXPath.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByXPath.java b/src/main/java/org/openqa/selenium/internal/FindsByXPath.java index 370880e95..c20fe6132 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByXPath.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByXPath.java @@ -1,6 +1,5 @@ /* Copyright 2007-2009 WebDriver committers -Copyright 2007-2009 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 33a1629048d3e27da34cdd3f4171f6a070266f86 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 14:43:31 +0000 Subject: [PATCH 042/114] SimonStewart: We haven't been just the webdriver project for a long time. We are now the selenium project. No logical changes. r16915 --- src/main/java/org/openqa/selenium/internal/FindsByXPath.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByXPath.java b/src/main/java/org/openqa/selenium/internal/FindsByXPath.java index c20fe6132..6deb142eb 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByXPath.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByXPath.java @@ -1,5 +1,5 @@ /* -Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Selenium committers Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 38e5bc3db1cb08ded0ea5c9de7289fc7f5978df1 Mon Sep 17 00:00:00 2001 From: Jason Leyba Date: Sat, 4 Apr 2015 18:34:01 -0700 Subject: [PATCH 043/114] For #401, apply a consistent copyright notice to the java/ tree. Uses a line-comment format rather than block comments for consistency across languages. --- .../selenium/internal/FindsByXPath.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/openqa/selenium/internal/FindsByXPath.java b/src/main/java/org/openqa/selenium/internal/FindsByXPath.java index 6deb142eb..49c0d72be 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByXPath.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByXPath.java @@ -1,18 +1,19 @@ -/* -Copyright 2007-2009 Selenium committers - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - */ +// Licensed to the Software Freedom Conservancy (SFC) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The SFC licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. package org.openqa.selenium.internal; From 4a65779bf283f0079706dfa6a3ed7330ec66f29d Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Tue, 1 Feb 2011 13:59:17 +0000 Subject: [PATCH 044/114] SimonStewart: Moving the vast bulk of the client-side code to the new java location r11226 --- .../java/org/openqa/selenium/WebElement.java | 174 ++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 src/main/java/org/openqa/selenium/WebElement.java diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java new file mode 100644 index 000000000..5ce00398e --- /dev/null +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -0,0 +1,174 @@ +/* +Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Google Inc. +Portions copyright 2007 ThoughtWorks, Inc + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package org.openqa.selenium; + +import java.util.List; + +/** + * Represents an HTML element. Generally, all interesting operations to do with interacting with a + * page will be performed through this interface. + *

+ * All method calls will do a freshness check to ensure that the element reference is still valid. + * This essentially determines whether or not the element is still attached to the DOM. If this test + * fails, then an {@link org.openqa.selenium.StaleElementReferenceException} is thrown, and all + * future calls to this instance will fail. + */ +public interface WebElement extends SearchContext { + /** + * Click this element. If this causes a new page to load, this method will block until the page + * has loaded. At this point, you should discard all references to this element and any further + * operations performed on this element will have undefined behaviour unless you know that the + * element and the page will still be present. If click() causes a new page to be loaded via an + * event or is done by sending a native event (which is a common case on Firefox, IE on Windows) + * then the method will *not* wait for it to be loaded and the caller should verify that a new + * page has been loaded. + *

+ * If this element is not clickable, then this operation is a no-op since it's pretty common for + * someone to accidentally miss the target when clicking in Real Life + */ + void click(); + + /** + * If this current element is a form, or an element within a form, then this will be submitted + * to the remote server. If this causes the current page to change, then this method will block + * until the new page is loaded. + * + * @throws NoSuchElementException If the given element is not within a form + */ + void submit(); + + /** + * Get the value of the element's "value" attribute. If this value has been modified after the + * page has loaded (for example, through javascript) then this will reflect the current value of + * the "value" attribute. + * + * @return The value of the element's "value" attribute. + * @see WebElement#getAttribute(String) + */ + String getValue(); + + /** + * Use this method to simulate typing into an element, which may set its value. + */ + void sendKeys(CharSequence... keysToSend); + + /** + * If this element is a text entry element, this will clear the value. Has no effect on other + * elements. Text entry elements are INPUT and TEXTAREA elements. + */ + void clear(); + + /** + * Get the tag name of this element. Not the value of the name attribute: will return + * "input" for the element <input name="foo" />. + * + * @return The tag name of this element. + */ + String getTagName(); + + /** + * Get the value of a the given attribute of the element. Will return the current value, even if + * this has been modified after the page has been loaded. More exactly, this method will return + * the value of the given attribute, unless that attribute is not present, in which case the + * value of the property with the same name is returned. If neither value is set, null is + * returned. The "style" attribute is converted as best can be to a text representation with a + * trailing semi-colon. The following are deemed to be "boolean" attributes, and will + * return either "true" or "false": + * + * async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked, + * defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, + * iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, + * nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, seeking, + * selected, spellcheck, truespeed, willvalidate + * + * Finally, the following commonly mis-capitalized attribute/property names are evaluated as + * expected: + * + *

    + *
  • "class" +
  • "readonly" + *
+ * + * @param name The name of the attribute. + * @return The attribute's current value or null if the value is not set. + */ + String getAttribute(String name); + + /** + * If the element is a checkbox this will toggle the elements state from selected to not + * selected, or from not selected to selected. + * + * @return Whether the toggled element is selected (true) or not (false) after this toggle is + * complete + */ + boolean toggle(); + + /** + * Determine whether or not this element is selected or not. This operation only applies to + * input elements such as checkboxes, options in a select and radio buttons. + * + * @return True if the element is currently selected or checked, false otherwise. + */ + boolean isSelected(); + + /** + * Select an element. This method will work against radio buttons, "option" elements within a + * "select" and checkboxes + */ + void setSelected(); + + /** + * Is the element currently enabled or not? This will generally return true for everything but + * disabled input elements. + * + * @return True if the element is enabled, false otherwise. + */ + boolean isEnabled(); + + /** + * Get the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, + * without any leading or trailing whitespace. + * + * @return The innerText of this element. + */ + String getText(); + + /** + * Find all elements within the current context using the given mechanism. When using xpath be + * aware that webdriver follows standard conventions: a search prefixed with "//" will search + * the entire document, not just the children of this current node. Use ".//" to limit your + * search to the children of this WebElement. + * + * @param by The locating mechanism to use + * @return A list of all {@link WebElement}s, or an empty list if nothing matches. + * @see org.openqa.selenium.By + */ + List findElements(By by); + + /** + * Find the first {@link WebElement} using the given method. See the note in + * {@link #findElement(By)} about finding via XPath. + * + * @param by The locating mechanism + * @return The first matching element on the current context. + * @throws NoSuchElementException If no matching elements are found + */ + WebElement findElement(By by); + +} From 188b9cf04f8a81eda21680b73f8ef315ec9c0a58 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 28 Mar 2011 10:48:41 +0000 Subject: [PATCH 045/114] SimonStewart: Deprecating the getValue method as it duplicates getAttribute('value') r11820 --- src/main/java/org/openqa/selenium/WebElement.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 5ce00398e..5be8f8f8d 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -60,7 +60,9 @@ public interface WebElement extends SearchContext { * * @return The value of the element's "value" attribute. * @see WebElement#getAttribute(String) + * @deprecated Use WebElement#getAttribute("value") instead. */ + @Deprecated String getValue(); /** From 044508f43bcbf710c9534e790d5658906f718415 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Fri, 8 Apr 2011 16:41:14 +0000 Subject: [PATCH 046/114] SimonStewart: Starting the process of deleting RenderedWebElement by lifting methods up to WebElement and deprecating the RWE. r11930 --- .../java/org/openqa/selenium/WebElement.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 5be8f8f8d..6aee82759 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -173,4 +173,40 @@ public interface WebElement extends SearchContext { */ WebElement findElement(By by); + /** + * Is this element displayed or not? This method avoids the problem of + * having to parse an element's "style" attribute. + * + * @return Whether or not the element is displayed + */ + boolean isDisplayed(); + + /** + * Where on the page is the top left-hand corner of the rendered + * element? + * + * @return A point, containing the location of the top left-hand corner + * of the element + */ + Point getLocation(); + + /** + * What is the width and height of the rendered element? + * + * @return The size of the element on the page. + */ + Dimension getSize(); + + /** + * Get the value of a given CSS property. This is probably not going to + * return what you expect it to unless you've already had a look at the + * element using something like firebug. Seriously, even then you'll be + * lucky for this to work cross-browser. Colour values should be returned + * as hex strings, so, for example if the "background-color" property is + * set as "green" in the HTML source, the returned value will be + * "#008000" + * + * @return The current, computed value of the property. + */ + String getCssValue(String propertyName); } From 64b32223e7591fd78f416d1c5cebec259fa65bad Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Thu, 2 Jun 2011 17:31:22 +0000 Subject: [PATCH 047/114] SimonStewart: Removing the deprecated getValue method r12346 --- src/main/java/org/openqa/selenium/WebElement.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 6aee82759..31ad573b2 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -53,18 +53,6 @@ public interface WebElement extends SearchContext { */ void submit(); - /** - * Get the value of the element's "value" attribute. If this value has been modified after the - * page has loaded (for example, through javascript) then this will reflect the current value of - * the "value" attribute. - * - * @return The value of the element's "value" attribute. - * @see WebElement#getAttribute(String) - * @deprecated Use WebElement#getAttribute("value") instead. - */ - @Deprecated - String getValue(); - /** * Use this method to simulate typing into an element, which may set its value. */ From 4c3f4427a40f1c12f3ac8ead61529fe060c7a592 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Sun, 12 Jun 2011 16:12:02 +0000 Subject: [PATCH 048/114] SimonStewart: Deprecating setSelected and toggle on WebElement r12457 --- src/main/java/org/openqa/selenium/WebElement.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 31ad573b2..872db7030 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -106,7 +106,9 @@ public interface WebElement extends SearchContext { * * @return Whether the toggled element is selected (true) or not (false) after this toggle is * complete + * @deprecated To be removed. Determine the current state using {@link #isSelected()} */ + @Deprecated boolean toggle(); /** @@ -120,7 +122,10 @@ public interface WebElement extends SearchContext { /** * Select an element. This method will work against radio buttons, "option" elements within a * "select" and checkboxes + * + * @deprecated Please use "click" instead */ + @Deprecated void setSelected(); /** From 8855b7b29dc1233632dd542b17566275578f1a5a Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 27 Jun 2011 10:01:02 +0000 Subject: [PATCH 049/114] SimonStewart: Deleting the deprecated toggle method r12635 --- src/main/java/org/openqa/selenium/WebElement.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 872db7030..01571b214 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -100,17 +100,6 @@ public interface WebElement extends SearchContext { */ String getAttribute(String name); - /** - * If the element is a checkbox this will toggle the elements state from selected to not - * selected, or from not selected to selected. - * - * @return Whether the toggled element is selected (true) or not (false) after this toggle is - * complete - * @deprecated To be removed. Determine the current state using {@link #isSelected()} - */ - @Deprecated - boolean toggle(); - /** * Determine whether or not this element is selected or not. This operation only applies to * input elements such as checkboxes, options in a select and radio buttons. From e00fa7161e5b2c5c7e0b6d31d623beb6d98a9366 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 27 Jun 2011 10:55:48 +0000 Subject: [PATCH 050/114] SimonStewart: Removing WebElement.setSelected from the java tree and the firefox driver. r12636 --- src/main/java/org/openqa/selenium/WebElement.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 01571b214..6b1492f87 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -108,15 +108,6 @@ public interface WebElement extends SearchContext { */ boolean isSelected(); - /** - * Select an element. This method will work against radio buttons, "option" elements within a - * "select" and checkboxes - * - * @deprecated Please use "click" instead - */ - @Deprecated - void setSelected(); - /** * Is the element currently enabled or not? This will generally return true for everything but * disabled input elements. From 1893b8a865eb6b60bf031c4f285997f127eea91c Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Wed, 24 Aug 2011 20:17:36 +0000 Subject: [PATCH 051/114] DanielWagnerHall: Bulk reformatting. Some changes may not be perfect; feel free to update if you disagree. r13571 --- .../java/org/openqa/selenium/WebElement.java | 86 +++++++++---------- 1 file changed, 41 insertions(+), 45 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 6b1492f87..4bf2262fb 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ + */ package org.openqa.selenium; @@ -45,9 +45,9 @@ public interface WebElement extends SearchContext { void click(); /** - * If this current element is a form, or an element within a form, then this will be submitted - * to the remote server. If this causes the current page to change, then this method will block - * until the new page is loaded. + * If this current element is a form, or an element within a form, then this will be submitted to + * the remote server. If this causes the current page to change, then this method will block until + * the new page is loaded. * * @throws NoSuchElementException If the given element is not within a form */ @@ -67,7 +67,7 @@ public interface WebElement extends SearchContext { /** * Get the tag name of this element. Not the value of the name attribute: will return * "input" for the element <input name="foo" />. - * + * * @return The tag name of this element. */ String getTagName(); @@ -75,35 +75,35 @@ public interface WebElement extends SearchContext { /** * Get the value of a the given attribute of the element. Will return the current value, even if * this has been modified after the page has been loaded. More exactly, this method will return - * the value of the given attribute, unless that attribute is not present, in which case the - * value of the property with the same name is returned. If neither value is set, null is - * returned. The "style" attribute is converted as best can be to a text representation with a - * trailing semi-colon. The following are deemed to be "boolean" attributes, and will - * return either "true" or "false": - * + * the value of the given attribute, unless that attribute is not present, in which case the value + * of the property with the same name is returned. If neither value is set, null is returned. The + * "style" attribute is converted as best can be to a text representation with a trailing + * semi-colon. The following are deemed to be "boolean" attributes, and will return either "true" + * or "false": + * * async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked, * defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, - * iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, - * nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, seeking, - * selected, spellcheck, truespeed, willvalidate - * + * iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, + * novalidate, nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, + * seeking, selected, spellcheck, truespeed, willvalidate + * * Finally, the following commonly mis-capitalized attribute/property names are evaluated as * expected: - * + * *
    *
  • "class" -
  • "readonly" + *
  • "readonly" *
- * + * * @param name The name of the attribute. * @return The attribute's current value or null if the value is not set. */ String getAttribute(String name); /** - * Determine whether or not this element is selected or not. This operation only applies to - * input elements such as checkboxes, options in a select and radio buttons. - * + * Determine whether or not this element is selected or not. This operation only applies to input + * elements such as checkboxes, options in a select and radio buttons. + * * @return True if the element is currently selected or checked, false otherwise. */ boolean isSelected(); @@ -111,7 +111,7 @@ public interface WebElement extends SearchContext { /** * Is the element currently enabled or not? This will generally return true for everything but * disabled input elements. - * + * * @return True if the element is enabled, false otherwise. */ boolean isEnabled(); @@ -119,17 +119,17 @@ public interface WebElement extends SearchContext { /** * Get the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, * without any leading or trailing whitespace. - * + * * @return The innerText of this element. */ String getText(); /** * Find all elements within the current context using the given mechanism. When using xpath be - * aware that webdriver follows standard conventions: a search prefixed with "//" will search - * the entire document, not just the children of this current node. Use ".//" to limit your - * search to the children of this WebElement. - * + * aware that webdriver follows standard conventions: a search prefixed with "//" will search the + * entire document, not just the children of this current node. Use ".//" to limit your search to + * the children of this WebElement. + * * @param by The locating mechanism to use * @return A list of all {@link WebElement}s, or an empty list if nothing matches. * @see org.openqa.selenium.By @@ -139,7 +139,7 @@ public interface WebElement extends SearchContext { /** * Find the first {@link WebElement} using the given method. See the note in * {@link #findElement(By)} about finding via XPath. - * + * * @param by The locating mechanism * @return The first matching element on the current context. * @throws NoSuchElementException If no matching elements are found @@ -147,38 +147,34 @@ public interface WebElement extends SearchContext { WebElement findElement(By by); /** - * Is this element displayed or not? This method avoids the problem of - * having to parse an element's "style" attribute. - * + * Is this element displayed or not? This method avoids the problem of having to parse an + * element's "style" attribute. + * * @return Whether or not the element is displayed */ boolean isDisplayed(); /** - * Where on the page is the top left-hand corner of the rendered - * element? - * - * @return A point, containing the location of the top left-hand corner - * of the element + * Where on the page is the top left-hand corner of the rendered element? + * + * @return A point, containing the location of the top left-hand corner of the element */ Point getLocation(); /** * What is the width and height of the rendered element? - * + * * @return The size of the element on the page. */ Dimension getSize(); /** - * Get the value of a given CSS property. This is probably not going to - * return what you expect it to unless you've already had a look at the - * element using something like firebug. Seriously, even then you'll be - * lucky for this to work cross-browser. Colour values should be returned - * as hex strings, so, for example if the "background-color" property is - * set as "green" in the HTML source, the returned value will be - * "#008000" - * + * Get the value of a given CSS property. This is probably not going to return what you expect it + * to unless you've already had a look at the element using something like firebug. Seriously, + * even then you'll be lucky for this to work cross-browser. Colour values should be returned as + * hex strings, so, for example if the "background-color" property is set as "green" in the HTML + * source, the returned value will be "#008000" + * * @return The current, computed value of the property. */ String getCssValue(String propertyName); From 624896b36d6b010859465b7d9c32246faaf4f67c Mon Sep 17 00:00:00 2001 From: Paul Hammant Date: Wed, 7 Sep 2011 17:35:33 +0000 Subject: [PATCH 052/114] paul hammant: Add Javadoc to describe the entanglement with implicit waits r13765 --- src/main/java/org/openqa/selenium/WebElement.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 4bf2262fb..7347eb7f5 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -129,20 +129,32 @@ public interface WebElement extends SearchContext { * aware that webdriver follows standard conventions: a search prefixed with "//" will search the * entire document, not just the children of this current node. Use ".//" to limit your search to * the children of this WebElement. + * This method is affected by the 'implicit wait' times in force at the time of execution. + * For example, that is 5 seconds, the findElements(..) after its first attempt to collect + * matching WebElements if there is at least one. If there were no matching WebElements + * after the first attempt, then the method will wait in line with the interval specified, + * then try again. It will keep going until it finds at least one WebElement in a pass, + * or the configured timeout is reached. * * @param by The locating mechanism to use * @return A list of all {@link WebElement}s, or an empty list if nothing matches. * @see org.openqa.selenium.By + * @see org.openqa.selenium.WebDriver.Timeouts */ List findElements(By by); /** * Find the first {@link WebElement} using the given method. See the note in * {@link #findElement(By)} about finding via XPath. + * This method is affected by the 'implicit wait' times in force at the time of execution. + * The findElement(..) invocation will return a matching row, or try again repeatedly until + * the configured timeout is reached. * * @param by The locating mechanism * @return The first matching element on the current context. * @throws NoSuchElementException If no matching elements are found + * @see org.openqa.selenium.By + * @see org.openqa.selenium.WebDriver.Timeouts */ WebElement findElement(By by); From ad876d9ef9782ad1f16e9f397e3de4a495c0c59f Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Fri, 9 Sep 2011 12:05:45 +0000 Subject: [PATCH 053/114] SimonStewart: Rewording some of the docs for findElements r13803 --- src/main/java/org/openqa/selenium/WebElement.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 7347eb7f5..d5e9db2fe 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -129,13 +129,10 @@ public interface WebElement extends SearchContext { * aware that webdriver follows standard conventions: a search prefixed with "//" will search the * entire document, not just the children of this current node. Use ".//" to limit your search to * the children of this WebElement. - * This method is affected by the 'implicit wait' times in force at the time of execution. - * For example, that is 5 seconds, the findElements(..) after its first attempt to collect - * matching WebElements if there is at least one. If there were no matching WebElements - * after the first attempt, then the method will wait in line with the interval specified, - * then try again. It will keep going until it finds at least one WebElement in a pass, - * or the configured timeout is reached. - * + * This method is affected by the 'implicit wait' times in force at the time of execution. When + * implicitly waiting, this method will return as soon as there are more than 0 items in the + * found collection, or will return an empty list if the timeout is reached. + * * @param by The locating mechanism to use * @return A list of all {@link WebElement}s, or an empty list if nothing matches. * @see org.openqa.selenium.By From c1a186d8e105f34d1071409233ac59d7d62216be Mon Sep 17 00:00:00 2001 From: Paul Hammant Date: Wed, 12 Oct 2011 15:57:27 +0000 Subject: [PATCH 054/114] Paul Hammant: ThoughtWorks code grant to SFC completed r14136 --- src/main/java/org/openqa/selenium/WebElement.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index d5e9db2fe..32c00282a 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -1,7 +1,7 @@ /* Copyright 2007-2009 WebDriver committers Copyright 2007-2009 Google Inc. -Portions copyright 2007 ThoughtWorks, Inc +Portions copyright 2011 Software Freedom Conservatory Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 8521a4ff82770d0ef99a2b904359b18b27b9dcaf Mon Sep 17 00:00:00 2001 From: Kristian Rosenvold Date: Sat, 19 Nov 2011 10:05:17 +0000 Subject: [PATCH 055/114] KristianRosenvold: Added javadoc note to findElement about using findElements for non-present elements r14821 --- src/main/java/org/openqa/selenium/WebElement.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 32c00282a..e17f8921c 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -146,7 +146,10 @@ public interface WebElement extends SearchContext { * This method is affected by the 'implicit wait' times in force at the time of execution. * The findElement(..) invocation will return a matching row, or try again repeatedly until * the configured timeout is reached. - * + * + * findElement should not be used to look for non-present elements, use {@link #findElements(By)} + * and assert zero length response instead. + * * @param by The locating mechanism * @return The first matching element on the current context. * @throws NoSuchElementException If no matching elements are found From 5ce224e18666561316e1e964ac71a7caee2b7510 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Sun, 11 Dec 2011 01:26:51 +0000 Subject: [PATCH 056/114] DanielWagnerHall: Clarifying shorthand vs longhand property behaviour r15150 --- src/main/java/org/openqa/selenium/WebElement.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index e17f8921c..b8f023b67 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -183,9 +183,16 @@ public interface WebElement extends SearchContext { /** * Get the value of a given CSS property. This is probably not going to return what you expect it * to unless you've already had a look at the element using something like firebug. Seriously, - * even then you'll be lucky for this to work cross-browser. Colour values should be returned as + * even then you'll be lucky for this to work cross-browser. Color values should be returned as * hex strings, so, for example if the "background-color" property is set as "green" in the HTML - * source, the returned value will be "#008000" + * source, the returned value will be "#008000". + * + * Note that shorthand CSS properties (e.g. background, font, border, border-top, margin, + * margin-top, padding, padding-top, list-style, outline, pause, cue) are not returned, + * in accordance with the + * DOM CSS2 specification + * - you should directly access the longhand properties (e.g. background-color) to access the + * desired values. * * @return The current, computed value of the property. */ From f614ed2a557228c1d41408a05cc68eaff319f5e6 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Fri, 16 Dec 2011 13:19:25 +0000 Subject: [PATCH 057/114] DanielWagnerHall: s/Conservatory/Conservancy/g r15204 --- src/main/java/org/openqa/selenium/WebElement.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index b8f023b67..c701f2b99 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -1,7 +1,7 @@ /* Copyright 2007-2009 WebDriver committers Copyright 2007-2009 Google Inc. -Portions copyright 2011 Software Freedom Conservatory +Portions copyright 2011 Software Freedom Conservancy Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 848c69f70967b678af2b750073cf85bda254bfcf Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Tue, 3 Jan 2012 20:43:26 +0000 Subject: [PATCH 058/114] DanielWagnerHall: Fix docs to indicate getAttribute returns null not false. Update issue 1497 Documentation updated r15353 --- src/main/java/org/openqa/selenium/WebElement.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index c701f2b99..d4e484bfc 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -79,7 +79,7 @@ public interface WebElement extends SearchContext { * of the property with the same name is returned. If neither value is set, null is returned. The * "style" attribute is converted as best can be to a text representation with a trailing * semi-colon. The following are deemed to be "boolean" attributes, and will return either "true" - * or "false": + * or null: * * async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked, * defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, From bb37a6d6b4df8923ed1c454300fa31f83bd9742f Mon Sep 17 00:00:00 2001 From: "Laskin@gmail.com" Date: Thu, 5 Apr 2012 14:11:13 +0000 Subject: [PATCH 059/114] LeoLaskin: updating with jleybay's comments from r16426. r16459 --- .../java/org/openqa/selenium/WebElement.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index d4e484bfc..ceaa1d260 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -31,16 +31,16 @@ */ public interface WebElement extends SearchContext { /** - * Click this element. If this causes a new page to load, this method will block until the page - * has loaded. At this point, you should discard all references to this element and any further - * operations performed on this element will have undefined behaviour unless you know that the - * element and the page will still be present. If click() causes a new page to be loaded via an - * event or is done by sending a native event (which is a common case on Firefox, IE on Windows) - * then the method will *not* wait for it to be loaded and the caller should verify that a new - * page has been loaded. + * Click this element. If this causes a new page to load, this method will attempt to block until + * the page has loaded. At this point, you should discard all references to this element and any + * further operations performed on this element will return a StaleElementReferenceError unless you know + * the element and the page will still be present. If click() causes a new page to be loaded via + * an event or is done by sending a native event then the method will *not* wait for it to be + * loaded and the caller should verify that a new page has been loaded. *

- * If this element is not clickable, then this operation is a no-op since it's pretty common for - * someone to accidentally miss the target when clicking in Real Life + * There are some preconditions for an element to be clicked. The element must be visible and + * it must have a height and width greater then 0. + */ void click(); From f9a8b3eb2a9169ed5bd40c02f51509b71d2fba34 Mon Sep 17 00:00:00 2001 From: "Laskin@gmail.com" Date: Thu, 5 Apr 2012 14:28:33 +0000 Subject: [PATCH 060/114] LeoLaskin: fixed per Jari's comments and added the @throws r16461 --- src/main/java/org/openqa/selenium/WebElement.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index ceaa1d260..5b04bd150 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -33,14 +33,15 @@ public interface WebElement extends SearchContext { /** * Click this element. If this causes a new page to load, this method will attempt to block until * the page has loaded. At this point, you should discard all references to this element and any - * further operations performed on this element will return a StaleElementReferenceError unless you know - * the element and the page will still be present. If click() causes a new page to be loaded via - * an event or is done by sending a native event then the method will *not* wait for it to be - * loaded and the caller should verify that a new page has been loaded. + * further operations performed on this element will throw a StaleElementReferenceException unless + * you know the element and the page will still be present. If click() causes a new page to be + * loaded via an event or is done by sending a native event then the method will *not* wait for + * it to be loaded and the caller should verify that a new page has been loaded. *

* There are some preconditions for an element to be clicked. The element must be visible and * it must have a height and width greater then 0. - + * + * @throws StaleElementReferenceException If the element no longer exists as initially defined */ void click(); From 11348876c11d52a4b9e5e26675ff14a6a11e65e6 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 10:53:46 +0000 Subject: [PATCH 061/114] SimonStewart: After a code grant, the code is copyright the SFC and the selenium committers. Starting to update the copyright headers r16908 --- src/main/java/org/openqa/selenium/WebElement.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 5b04bd150..606370b6d 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -1,6 +1,5 @@ /* Copyright 2007-2009 WebDriver committers -Copyright 2007-2009 Google Inc. Portions copyright 2011 Software Freedom Conservancy Licensed under the Apache License, Version 2.0 (the "License"); From c8a2233c47214f48eae2a0f8182062db694654c6 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 14:43:31 +0000 Subject: [PATCH 062/114] SimonStewart: We haven't been just the webdriver project for a long time. We are now the selenium project. No logical changes. r16915 --- src/main/java/org/openqa/selenium/WebElement.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 606370b6d..5dea06d1e 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -1,5 +1,5 @@ /* -Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Selenium committers Portions copyright 2011 Software Freedom Conservancy Licensed under the Apache License, Version 2.0 (the "License"); From 81f2bc32e1267b5691d3ea36761e8c80ef6e87ee Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Wed, 20 Jun 2012 16:41:43 +0000 Subject: [PATCH 063/114] DanielWagnerHall for BobSilverberg: Color standardization for HtmlUnitDriver. Fixes issue 4043. r17234 --- src/main/java/org/openqa/selenium/WebElement.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 5dea06d1e..9e1f15a5f 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -181,12 +181,11 @@ public interface WebElement extends SearchContext { Dimension getSize(); /** - * Get the value of a given CSS property. This is probably not going to return what you expect it - * to unless you've already had a look at the element using something like firebug. Seriously, - * even then you'll be lucky for this to work cross-browser. Color values should be returned as - * hex strings, so, for example if the "background-color" property is set as "green" in the HTML - * source, the returned value will be "#008000". - * + * Get the value of a given CSS property. + * Color values should be returned as rgba strings, so, + * for example if the "background-color" property is set as "green" in the + * HTML source, the returned value will be "rgba(0, 255, 0, 1)". + * * Note that shorthand CSS properties (e.g. background, font, border, border-top, margin, * margin-top, padding, padding-top, list-style, outline, pause, cue) are not returned, * in accordance with the From a0eb398c9939d170a09d0e8fc9b960246c6bcb8b Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Fri, 22 Jun 2012 14:21:31 +0000 Subject: [PATCH 064/114] DanielWagnerHall: Clarify event behaviour of WebElement#clear r17257 --- src/main/java/org/openqa/selenium/WebElement.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 9e1f15a5f..7d3229714 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -61,6 +61,12 @@ public interface WebElement extends SearchContext { /** * If this element is a text entry element, this will clear the value. Has no effect on other * elements. Text entry elements are INPUT and TEXTAREA elements. + * + * Note that the events fired by this event may not be as you'd expect. In particular, we don't + * fire any keyboard or mouse events. If you want to ensure keyboard events are fired, consider + * using something like {@link #sendKeys(CharSequence...)} with the backspace key. To ensure + * you get a change event, consider following with a call to {@link #sendKeys(CharSequence...)} + * with the tab key. */ void clear(); From 78f79f96807f888fd256cf5ae24b34f445397e6a Mon Sep 17 00:00:00 2001 From: Alexei Barantsev Date: Tue, 9 Oct 2012 09:00:30 +0000 Subject: [PATCH 065/114] AlexeiBarantsev: Fixing link in javadoc. Fixes issue 4627 r17937 --- src/main/java/org/openqa/selenium/WebElement.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 7d3229714..08c50b1c4 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -148,7 +148,7 @@ public interface WebElement extends SearchContext { /** * Find the first {@link WebElement} using the given method. See the note in - * {@link #findElement(By)} about finding via XPath. + * {@link #findElements(By)} about finding via XPath. * This method is affected by the 'implicit wait' times in force at the time of execution. * The findElement(..) invocation will return a matching row, or try again repeatedly until * the configured timeout is reached. From dfecb8dbf4818c3b873fec77e2964eca2cbecc66 Mon Sep 17 00:00:00 2001 From: Kristian Rosenvold Date: Fri, 11 Jan 2013 22:18:32 +0100 Subject: [PATCH 066/114] KristianRosenvold: Removed windows carriage returns From 7636f6b7a8354b04a11fbbb6e236cf09105e10e9 Mon Sep 17 00:00:00 2001 From: Alexei Barantsev Date: Fri, 11 Oct 2013 16:32:24 +0400 Subject: [PATCH 067/114] Fixing Javadoc for getAttribute. Fixes issue 2443 --- src/main/java/org/openqa/selenium/WebElement.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 08c50b1c4..af7e94d91 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -82,10 +82,10 @@ public interface WebElement extends SearchContext { * Get the value of a the given attribute of the element. Will return the current value, even if * this has been modified after the page has been loaded. More exactly, this method will return * the value of the given attribute, unless that attribute is not present, in which case the value - * of the property with the same name is returned. If neither value is set, null is returned. The - * "style" attribute is converted as best can be to a text representation with a trailing - * semi-colon. The following are deemed to be "boolean" attributes, and will return either "true" - * or null: + * of the property with the same name is returned (for example for the "value" property of a + * textarea element). If neither value is set, null is returned. The "style" attribute is + * converted as best can be to a text representation with a trailing semi-colon. The following are + * deemed to be "boolean" attributes, and will return either "true" or null: * * async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked, * defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, @@ -102,7 +102,7 @@ public interface WebElement extends SearchContext { * * * @param name The name of the attribute. - * @return The attribute's current value or null if the value is not set. + * @return The attribute/property's current value or null if the value is not set. */ String getAttribute(String name); From 18cd3a2e0cf18dda71acf0b3b170201e03222ca1 Mon Sep 17 00:00:00 2001 From: Luke Inman-Semerau Date: Thu, 26 Feb 2015 15:44:48 -0800 Subject: [PATCH 068/114] updating javadocs / fixing javadoc errors built using java 8 --- src/main/java/org/openqa/selenium/WebElement.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index af7e94d91..83deac9be 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -22,7 +22,7 @@ /** * Represents an HTML element. Generally, all interesting operations to do with interacting with a * page will be performed through this interface. - *

+ *

* All method calls will do a freshness check to ensure that the element reference is still valid. * This essentially determines whether or not the element is still attached to the DOM. If this test * fails, then an {@link org.openqa.selenium.StaleElementReferenceException} is thrown, and all @@ -36,7 +36,7 @@ public interface WebElement extends SearchContext { * you know the element and the page will still be present. If click() causes a new page to be * loaded via an event or is done by sending a native event then the method will *not* wait for * it to be loaded and the caller should verify that a new page has been loaded. - *

+ *

* There are some preconditions for an element to be clicked. The element must be visible and * it must have a height and width greater then 0. * From b6d303da4db120bddbaa6f411da4e5263cd194bc Mon Sep 17 00:00:00 2001 From: Harry Date: Fri, 5 Sep 2014 08:45:14 +0000 Subject: [PATCH 069/114] java: mention native events in docs for WebElement.click Signed-off-by: Andreas Tolfsen --- .../java/org/openqa/selenium/WebElement.java | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 83deac9be..4c578cebb 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -1,6 +1,6 @@ /* Copyright 2007-2009 Selenium committers -Portions copyright 2011 Software Freedom Conservancy +Portions copyright 2011-2015 Software Freedom Conservancy Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -30,17 +30,23 @@ */ public interface WebElement extends SearchContext { /** - * Click this element. If this causes a new page to load, this method will attempt to block until - * the page has loaded. At this point, you should discard all references to this element and any - * further operations performed on this element will throw a StaleElementReferenceException unless - * you know the element and the page will still be present. If click() causes a new page to be - * loaded via an event or is done by sending a native event then the method will *not* wait for - * it to be loaded and the caller should verify that a new page has been loaded. - *

- * There are some preconditions for an element to be clicked. The element must be visible and - * it must have a height and width greater then 0. + * Click this element. If this causes a new page to load, you + * should discard all references to this element and any further + * operations performed on this element will throw a + * StaleElementReferenceException. * - * @throws StaleElementReferenceException If the element no longer exists as initially defined + * Note that if click() is done by sending a native event (which is + * the default on most browsers/platforms) then the method will + * _not_ wait for the next page to load and the caller should verify + * that themselves. + + * + * There are some preconditions for an element to be clicked. The + * element must be visible and it must have a height and width + * greater then 0. + * + * @throws StaleElementReferenceException If the element no + * longer exists as initially defined */ void click(); From 9de88d06fb125204567d6ced8ba7b962baa68aee Mon Sep 17 00:00:00 2001 From: Jason Leyba Date: Sat, 4 Apr 2015 18:34:01 -0700 Subject: [PATCH 070/114] For #401, apply a consistent copyright notice to the java/ tree. Uses a line-comment format rather than block comments for consistency across languages. --- .../java/org/openqa/selenium/WebElement.java | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 4c578cebb..503ead20e 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -1,19 +1,19 @@ -/* -Copyright 2007-2009 Selenium committers -Portions copyright 2011-2015 Software Freedom Conservancy - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - */ +// Licensed to the Software Freedom Conservancy (SFC) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The SFC licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. package org.openqa.selenium; @@ -54,7 +54,7 @@ public interface WebElement extends SearchContext { * If this current element is a form, or an element within a form, then this will be submitted to * the remote server. If this causes the current page to change, then this method will block until * the new page is loaded. - * + * * @throws NoSuchElementException If the given element is not within a form */ void submit(); @@ -79,7 +79,7 @@ public interface WebElement extends SearchContext { /** * Get the tag name of this element. Not the value of the name attribute: will return * "input" for the element <input name="foo" />. - * + * * @return The tag name of this element. */ String getTagName(); @@ -92,21 +92,21 @@ public interface WebElement extends SearchContext { * textarea element). If neither value is set, null is returned. The "style" attribute is * converted as best can be to a text representation with a trailing semi-colon. The following are * deemed to be "boolean" attributes, and will return either "true" or null: - * + * * async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked, * defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, * iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, * novalidate, nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, * seeking, selected, spellcheck, truespeed, willvalidate - * + * * Finally, the following commonly mis-capitalized attribute/property names are evaluated as * expected: - * + * *

    *
  • "class" *
  • "readonly" *
- * + * * @param name The name of the attribute. * @return The attribute/property's current value or null if the value is not set. */ @@ -115,7 +115,7 @@ public interface WebElement extends SearchContext { /** * Determine whether or not this element is selected or not. This operation only applies to input * elements such as checkboxes, options in a select and radio buttons. - * + * * @return True if the element is currently selected or checked, false otherwise. */ boolean isSelected(); @@ -123,7 +123,7 @@ public interface WebElement extends SearchContext { /** * Is the element currently enabled or not? This will generally return true for everything but * disabled input elements. - * + * * @return True if the element is enabled, false otherwise. */ boolean isEnabled(); @@ -131,7 +131,7 @@ public interface WebElement extends SearchContext { /** * Get the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, * without any leading or trailing whitespace. - * + * * @return The innerText of this element. */ String getText(); @@ -156,7 +156,7 @@ public interface WebElement extends SearchContext { * Find the first {@link WebElement} using the given method. See the note in * {@link #findElements(By)} about finding via XPath. * This method is affected by the 'implicit wait' times in force at the time of execution. - * The findElement(..) invocation will return a matching row, or try again repeatedly until + * The findElement(..) invocation will return a matching row, or try again repeatedly until * the configured timeout is reached. * * findElement should not be used to look for non-present elements, use {@link #findElements(By)} @@ -173,21 +173,21 @@ public interface WebElement extends SearchContext { /** * Is this element displayed or not? This method avoids the problem of having to parse an * element's "style" attribute. - * + * * @return Whether or not the element is displayed */ boolean isDisplayed(); /** * Where on the page is the top left-hand corner of the rendered element? - * + * * @return A point, containing the location of the top left-hand corner of the element */ Point getLocation(); /** * What is the width and height of the rendered element? - * + * * @return The size of the element on the page. */ Dimension getSize(); @@ -204,7 +204,7 @@ public interface WebElement extends SearchContext { * DOM CSS2 specification * - you should directly access the longhand properties (e.g. background-color) to access the * desired values. - * + * * @return The current, computed value of the property. */ String getCssValue(String propertyName); From 0673413aa968cc5731d90b78cffe5e460220d66d Mon Sep 17 00:00:00 2001 From: Luke Inman-Semerau Date: Fri, 26 Jun 2015 16:05:08 -0700 Subject: [PATCH 071/114] adding TakesScreenshot to WebElement, not going down the Augmentor route right now since that is setup just for WebDriver. If someone really really likes the augmentor pattern, they can update it to also take into consideration WebElements and look at the Parent Driver instance's capabilities to determine which roles (interfaces) should be applied. I don't really care for it much and would rather get an exception from the driver that it is not implemented :) --- src/main/java/org/openqa/selenium/WebElement.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 503ead20e..aefd43a02 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -28,7 +28,7 @@ * fails, then an {@link org.openqa.selenium.StaleElementReferenceException} is thrown, and all * future calls to this instance will fail. */ -public interface WebElement extends SearchContext { +public interface WebElement extends SearchContext, TakesScreenshot { /** * Click this element. If this causes a new page to load, you * should discard all references to this element and any further From 648c87496dfcae4f705fb91bfa2df655121d41ca Mon Sep 17 00:00:00 2001 From: Luke Inman-Semerau Date: Thu, 24 Sep 2015 15:19:42 -0700 Subject: [PATCH 072/114] first pass at fixing some of the javadoc errors... still quite a few to go --- src/main/java/org/openqa/selenium/WebElement.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index aefd43a02..7ef9697ab 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -61,6 +61,8 @@ public interface WebElement extends SearchContext, TakesScreenshot { /** * Use this method to simulate typing into an element, which may set its value. + * + * @param keysToSend character sequence to send to the element */ void sendKeys(CharSequence... keysToSend); @@ -205,6 +207,7 @@ public interface WebElement extends SearchContext, TakesScreenshot { * - you should directly access the longhand properties (e.g. background-color) to access the * desired values. * + * @param propertyName the css property name of the element * @return The current, computed value of the property. */ String getCssValue(String propertyName); From 64ac62caaa16d8fa18df042fb7ccdeb8fabf0c44 Mon Sep 17 00:00:00 2001 From: Luke Inman-Semerau Date: Thu, 12 Nov 2015 11:34:59 -0800 Subject: [PATCH 073/114] adding selenium server pass throughs for W3C dialect of alert / window / cookie commands. changing how W3C dialect is detected by checking if 'status' is sent in the new session response switch to window in w3c passes in 'handle' variable instead of 'name' Fixes #1242 Fixes #1241 Fixes #1240 Fixes #1238 Fixes #1237 --- src/main/java/org/openqa/selenium/WebElement.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 7ef9697ab..4887d7fe6 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -194,6 +194,11 @@ public interface WebElement extends SearchContext, TakesScreenshot { */ Dimension getSize(); + /** + * @return The location and size of the rendered element + */ + Rectangle getRect(); + /** * Get the value of a given CSS property. * Color values should be returned as rgba strings, so, From fdb29bdb635c3b6566bf3df3111d40e38fe0b598 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Tue, 1 Feb 2011 13:59:17 +0000 Subject: [PATCH 074/114] SimonStewart: Moving the vast bulk of the client-side code to the new java location r11226 --- .../java/org/openqa/selenium/WebDriver.java | 398 ++++++++++++++++++ 1 file changed, 398 insertions(+) create mode 100644 src/main/java/org/openqa/selenium/WebDriver.java diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java new file mode 100644 index 000000000..b5ecca0b3 --- /dev/null +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -0,0 +1,398 @@ +/* +Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Google Inc. +Portions copyright 2007 ThoughtWorks, Inc + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package org.openqa.selenium; + +import java.net.URL; +import java.util.List; +import java.util.Set; +import java.util.concurrent.TimeUnit; + + +/** + * The main interface to use for testing, which represents an idealised web + * browser. The methods in this class fall into three categories: + *

+ *

    + *
  • Control of the browser itself
  • + *
  • Selection of {@link WebElement}s
  • + *
  • Debugging aids
  • + *
+ *

+ * Key methods are {@link WebDriver#get(String)}, which is used to load a new + * web page, and the various methods similar to + * {@link WebDriver#findElement(By)}, which is used to find + * {@link WebElement}s. + *

+ * Currently, you will need to instantiate implementations of this class + * directly. It is hoped that you write your tests against this interface so + * that you may "swap in" a more fully featured browser when there is a + * requirement for one. Given this approach to testing, it is best to start + * writing your tests using the {@link org.openqa.selenium.htmlunit.HtmlUnitDriver} implementation. + *

+ * Note that all methods that use XPath to locate elements will throw a + * {@link RuntimeException} should there be an error thrown by the underlying + * XPath engine. + * + * @see org.openqa.selenium.ie.InternetExplorerDriver + * @see org.openqa.selenium.htmlunit.HtmlUnitDriver + */ +public interface WebDriver extends SearchContext { + // Navigation + + /** + * Load a new web page in the current browser window. This is done using an + * HTTP GET operation, and the method will block until the load is complete. + * This will follow redirects issued either by the server or as a + * meta-redirect from within the returned HTML. Should a meta-redirect + * "rest" for any duration of time, it is best to wait until this timeout is + * over, since should the underlying page change whilst your test is + * executing the results of future calls against this interface will be + * against the freshly loaded page. Synonym for + * {@link org.openqa.selenium.WebDriver.Navigation#to(String)}. + * + * @param url The URL to load. It is best to use a fully qualified URL + */ + void get(String url); + + /** + * Get a string representing the current URL that the browser is looking at. + * + * @return The URL of the page currently loaded in the browser + */ + String getCurrentUrl(); + + // General properties + + /** + * The title of the current page. + * + * @return The title of the current page, + * with leading and trailing whitespace stripped, + * or null if one is not already set + */ + String getTitle(); + + /** + * Find all elements within the current page using the given mechanism. + * + * @param by The locating mechanism to use + * @return A list of all {@link WebElement}s, or an empty list if nothing matches + * @see org.openqa.selenium.By + */ + List findElements(By by); + + + /** + * Find the first {@link WebElement} using the given method. + * + * @param by The locating mechanism + * @return The first matching element on the current page + * @throws NoSuchElementException If no matching elements are found + */ + WebElement findElement(By by); + + // Misc + + /** + * Get the source of the last loaded page. If the page has been modified + * after loading (for example, by Javascript) there is no guarentee that the + * returned text is that of the modified page. Please consult the + * documentation of the particular driver being used to determine whether + * the returned text reflects the current state of the page or the text last + * sent by the web server. The page source returned is a representation of + * the underlying DOM: do not expect it to be formatted or escaped in the same + * way as the response sent from the web server. + * + * @return The source of the current page + */ + String getPageSource(); + + /** + * Close the current window, quitting the browser if it's the last window + * currently open. + */ + void close(); + + /** + * Quits this driver, closing every associated window. + */ + void quit(); + + /** + * Return a set of window handles which can be used to iterate over all open windows of + * this webdriver instance by passing them to {@link #switchTo().window(String)} + * + * @return A set of window handles which can be used to iterate over all open windows. + */ + Set getWindowHandles(); + + /** + * Return an opaque handle to this window that uniquely identifies it within this driver + * instance. This can be used to switch to this window at a later date + */ + String getWindowHandle(); + + /** + * Send future commands to a different frame or window. + * + * @return A TargetLocator which can be used to select a frame or window + * @see org.openqa.selenium.WebDriver.TargetLocator + */ + TargetLocator switchTo(); + + /** + * An abstraction allowing the driver to access the browser's history and to + * navigate to a given URL. + * + * @return A {@link org.openqa.selenium.WebDriver.Navigation} that allows + * the selection of what to do next + */ + Navigation navigate(); + + /** + * Gets the Option interface + * + * @return An option interface + * @see org.openqa.selenium.WebDriver.Options + */ + Options manage(); + + /** + * An interface for managing stuff you would do in a browser menu + */ + interface Options { + + /** + * Add a specific cookie. If the cookie's domain name is left blank, it + * is assumed that the cookie is meant for the domain of the current + * document. + * + * @param cookie The cookie to add. + */ + void addCookie(Cookie cookie); + + /** + * Delete the named cookie from the current domain. This is equivalent + * to setting the named cookie's expiry date to some time in the past. + * + * @param name The name of the cookie to delete + */ + void deleteCookieNamed(String name); + + /** + * Delete a cookie from the browser's "cookie jar". The domain of the + * cookie will be ignored. + * + * @param cookie + */ + void deleteCookie(Cookie cookie); + + /** + * Delete all the cookies for the current domain. + */ + void deleteAllCookies(); + + /** + * Get all the cookies for the current domain. This is the equivalent of + * calling "document.cookie" and parsing the result + * + * @return A Set of cookies for the current domain. + */ + Set getCookies(); + + /** + * Get a cookie with a given name. + * + * @param name the name of the cookie + * @return the cookie, or null if no cookie with the given name is present + */ + Cookie getCookieNamed(String name); + + /** + * Gets the mouse speed for drag and drop. + * + * @deprecated This method is being reviewed. + */ + @Deprecated + Speed getSpeed(); + + /** + * Sets the speed for user input + * + * @param speed + * @deprecated This method is being reviewed. + */ + @Deprecated + void setSpeed(Speed speed); + + /** + * Returns the interface for managing driver timeouts. + */ + Timeouts timeouts(); + } + + /** + * An interface for managing timeout behavior for WebDriver instances. + */ + interface Timeouts { + + /** + * Specifies the amount of time the driver should wait when searching for an + * element if it is not immediately present. + *

+ * When searching for a single element, the driver should poll the page + * until the element has been found, or this timeout expires before throwing + * a {@link NoSuchElementException}. When searching for multiple elements, + * the driver should poll the page until at least one element has been found + * or this timeout has expired. + *

+ * Increasing the implicit wait timeout should be used judiciously as it + * will have an adverse effect on test run time, especially when used with + * slower location strategies like XPath. + * + * @param time The amount of time to wait. + * @param unit The unit of measure for {@code time}. + * @return A self reference. + */ + Timeouts implicitlyWait(long time, TimeUnit unit); + + /** + * Sets the amount of time to wait for an asynchronous script to finish + * execution before throwing an error. If the timeout is negative, then the + * script will be allowed to run indefinitely. + * + * @param time The timeout value. + * @param unit The unit of time. + * @return A self reference. + * @see JavascriptExecutor#executeAsyncScript(String, Object...) + */ + Timeouts setScriptTimeout(long time, TimeUnit unit); + } + + /** + * Used to locate a given frame or window. + */ + interface TargetLocator { + /** + * Select a frame by its (zero-based) index. That is, if a page has + * three frames, the first frame would be at index "0", the second at + * index "1" and the third at index "2". Once the frame has been + * selected, all subsequent calls on the WebDriver interface are made to + * that frame. + * + * @param index (zero-based) index + * @return This driver focused on the given frame + * @throws NoSuchFrameException If the frame cannot be found + */ + WebDriver frame(int index); + + /** + * Select a frame by its name or ID. Frames located by matching name + * attributes are always given precedence over those matched by ID. + * + * @param nameOrId the name of the frame window, the id of the + * <frame> or <iframe> element, or the (zero-based) index + * @return This driver focused on the given frame + * @throws NoSuchFrameException If the frame cannot be found + */ + WebDriver frame(String nameOrId); + + /** + * Select a frame using its previously located {@link WebElement}. + * + * @param frameElement The frame element to switch to. + * @return This driver focused on the given frame. + * @throws NoSuchFrameException If the given element is neither an IFRAME + * nor a FRAME element. + * @throws StaleElementReferenceException If the WebElement has gone stale. + * @see WebDriver#findElement(By) + */ + WebDriver frame(WebElement frameElement); + + /** + * Switch the focus of future commands for this driver to the window with the given name/handle. + * + * @param nameOrHandle The name of the window or the handle as returned by {@link WebDriver#getWindowHandle()} + * @return This driver focused on the given window + * @throws NoSuchWindowException If the window cannot be found + */ + WebDriver window(String nameOrHandle); + + /** + * Selects either the first frame on the page, or the main document when a page contains iframes. + * + * @return This driver focused on the top window/first frame. + */ + WebDriver defaultContent(); + + /** + * Switches to the element that currently has focus, or the body element if this cannot be detected. + * + * @return The WebElement with focus, or the body element if no element with focus can be detected. + */ + WebElement activeElement(); + + /** + * Switches to the currently active modal dialog for this particular driver instance. + * + * @return A handle to the dialog. + */ + Alert alert(); + } + + interface Navigation { + /** + * Move back a single "item" in the browser's history. + */ + void back(); + + /** + * Move a single "item" forward in the browser's history. Does nothing if + * we are on the latest page viewed. + */ + void forward(); + + + /** + * Load a new web page in the current browser window. This is done using an + * HTTP GET operation, and the method will block until the load is complete. + * This will follow redirects issued either by the server or as a + * meta-redirect from within the returned HTML. Should a meta-redirect + * "rest" for any duration of time, it is best to wait until this timeout is + * over, since should the underlying page change whilst your test is + * executing the results of future calls against this interface will be + * against the freshly loaded page. + * + * @param url The URL to load. It is best to use a fully qualified URL + */ + void to(String url); + + /** + * Overloaded version of {@link #to(String)} that makes it easy to pass in a URL. + * + * @param url + */ + void to(URL url); + + /** + * Refresh the current page + */ + void refresh(); + } +} From 4a317258ea06891a239432a827a57e29315ff0d4 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Wed, 16 Feb 2011 16:21:39 +0000 Subject: [PATCH 075/114] SimonStewart: Deleting the deprecated 'Speed' class and methods that use it r11466 --- .../java/org/openqa/selenium/WebDriver.java | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index b5ecca0b3..85d0148c3 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -224,23 +224,6 @@ interface Options { */ Cookie getCookieNamed(String name); - /** - * Gets the mouse speed for drag and drop. - * - * @deprecated This method is being reviewed. - */ - @Deprecated - Speed getSpeed(); - - /** - * Sets the speed for user input - * - * @param speed - * @deprecated This method is being reviewed. - */ - @Deprecated - void setSpeed(Speed speed); - /** * Returns the interface for managing driver timeouts. */ From 09480d58846deb4f4eb5a28db15071fad8f6971d Mon Sep 17 00:00:00 2001 From: Eran Mes Date: Mon, 7 Mar 2011 18:07:42 +0000 Subject: [PATCH 076/114] EranMes: Allow controlling IME engines on Windows and Linux, code contributed by Timothe Faudot. Wire protocol documentation soon to follow. r11612 --- .../java/org/openqa/selenium/WebDriver.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 85d0148c3..724e2d531 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -228,6 +228,12 @@ interface Options { * Returns the interface for managing driver timeouts. */ Timeouts timeouts(); + + /** + * Returns the interface for controlling IME engines to generate + * complex-script input. + */ + ImeHandler ime(); } /** @@ -378,4 +384,54 @@ interface Navigation { */ void refresh(); } + + /** + * An interface for managing input methods. + */ + interface ImeHandler { + /** + * All available engines on the machine. To use an engine, it has to be activated. + * @return list of available IME engines. + * @throws ImeNotAvailableException if the host does not support IME. + */ + List getAvailableEngines(); + + /** + * Get the name of the active IME engine. The name string is platform-specific. + * @return name of the active IME engine. + * @throws ImeNotAvailableException if the host does not support IME. + */ + String getActiveEngine(); + + /** + * Indicates whether IME input active at the moment (not if it's available). + * @return true if IME input is available and currently active, false otherwise. + * @throws ImeNotAvailableException if the host does not support IME. + */ + boolean isActivated(); + + /** + * De-activate IME input (turns off the currently activated engine). Note that getActiveEngine + * may still return the name of the engine but isActivated will return false. + * @throws ImeNotAvailableException if the host does not support IME. + */ + void deactivate(); + + /** + * Make an engines that is available (appears on the list returned by getAvailableEngines) + * active. After this call, the only loaded engine on the IME daemon will be this one and the + * input sent using sendKeys will be converted by the engine. + * Noteh that this is a platform-independent method of activating IME + * (the platform-specific way being using keyboard shortcuts). + + * + * @param engine name of engine to activate. + * @return true if engine was loaded successfully, false if the engine is not an available one + * or IME activation failed. + * @throws ImeNotAvailableException if the host does not support IME. + * @throws ImeActivationFailedException if the engine is not available or if activation failed + * for other reasons. + */ + boolean activateEngine(String engine); + } } From 89b75370200e9b30717f96230607b268aca3e45d Mon Sep 17 00:00:00 2001 From: Eran Mes Date: Tue, 8 Mar 2011 16:54:04 +0000 Subject: [PATCH 077/114] EranMes: Removing the boolean from the activateEngine call, as an exception will be thrown if IME engine activation will fail. r11627 --- src/main/java/org/openqa/selenium/WebDriver.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 724e2d531..ec7329e05 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -426,12 +426,10 @@ interface ImeHandler { * * @param engine name of engine to activate. - * @return true if engine was loaded successfully, false if the engine is not an available one - * or IME activation failed. * @throws ImeNotAvailableException if the host does not support IME. * @throws ImeActivationFailedException if the engine is not available or if activation failed * for other reasons. */ - boolean activateEngine(String engine); + void activateEngine(String engine); } } From 006e2b12c9e07118edf876f4cd143bfd57e1ee77 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 23 May 2011 14:54:31 +0000 Subject: [PATCH 078/114] SimonStewart: Amending the description of activeElement to be clearer about what it does r12235 --- src/main/java/org/openqa/selenium/WebDriver.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index ec7329e05..e544986d4 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -331,7 +331,9 @@ interface TargetLocator { WebDriver defaultContent(); /** - * Switches to the element that currently has focus, or the body element if this cannot be detected. + * Switches to the element that currently has focus within the document currently "switched to", + * or the body element if this cannot be detected. This matches the semantics of calling + * "document.activeElement" in Javascript. * * @return The WebElement with focus, or the body element if no element with focus can be detected. */ From 6129780eb48b7b50e333dd05f4708b85f40e7601 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Wed, 24 Aug 2011 20:17:36 +0000 Subject: [PATCH 079/114] DanielWagnerHall: Bulk reformatting. Some changes may not be perfect; feel free to update if you disagree. r13571 --- .../java/org/openqa/selenium/WebDriver.java | 235 +++++++++--------- 1 file changed, 112 insertions(+), 123 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index e544986d4..ec1e5e321 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ + */ package org.openqa.selenium; @@ -25,8 +25,8 @@ /** - * The main interface to use for testing, which represents an idealised web - * browser. The methods in this class fall into three categories: + * The main interface to use for testing, which represents an idealised web browser. The methods in + * this class fall into three categories: *

*

    *
  • Control of the browser itself
  • @@ -34,21 +34,18 @@ *
  • Debugging aids
  • *
*

- * Key methods are {@link WebDriver#get(String)}, which is used to load a new - * web page, and the various methods similar to - * {@link WebDriver#findElement(By)}, which is used to find + * Key methods are {@link WebDriver#get(String)}, which is used to load a new web page, and the + * various methods similar to {@link WebDriver#findElement(By)}, which is used to find * {@link WebElement}s. *

- * Currently, you will need to instantiate implementations of this class - * directly. It is hoped that you write your tests against this interface so - * that you may "swap in" a more fully featured browser when there is a - * requirement for one. Given this approach to testing, it is best to start + * Currently, you will need to instantiate implementations of this class directly. It is hoped that + * you write your tests against this interface so that you may "swap in" a more fully featured + * browser when there is a requirement for one. Given this approach to testing, it is best to start * writing your tests using the {@link org.openqa.selenium.htmlunit.HtmlUnitDriver} implementation. *

- * Note that all methods that use XPath to locate elements will throw a - * {@link RuntimeException} should there be an error thrown by the underlying - * XPath engine. - * + * Note that all methods that use XPath to locate elements will throw a {@link RuntimeException} + * should there be an error thrown by the underlying XPath engine. + * * @see org.openqa.selenium.ie.InternetExplorerDriver * @see org.openqa.selenium.htmlunit.HtmlUnitDriver */ @@ -56,23 +53,21 @@ public interface WebDriver extends SearchContext { // Navigation /** - * Load a new web page in the current browser window. This is done using an - * HTTP GET operation, and the method will block until the load is complete. - * This will follow redirects issued either by the server or as a - * meta-redirect from within the returned HTML. Should a meta-redirect - * "rest" for any duration of time, it is best to wait until this timeout is - * over, since should the underlying page change whilst your test is - * executing the results of future calls against this interface will be - * against the freshly loaded page. Synonym for + * Load a new web page in the current browser window. This is done using an HTTP GET operation, + * and the method will block until the load is complete. This will follow redirects issued either + * by the server or as a meta-redirect from within the returned HTML. Should a meta-redirect + * "rest" for any duration of time, it is best to wait until this timeout is over, since should + * the underlying page change whilst your test is executing the results of future calls against + * this interface will be against the freshly loaded page. Synonym for * {@link org.openqa.selenium.WebDriver.Navigation#to(String)}. - * + * * @param url The URL to load. It is best to use a fully qualified URL */ void get(String url); /** * Get a string representing the current URL that the browser is looking at. - * + * * @return The URL of the page currently loaded in the browser */ String getCurrentUrl(); @@ -81,16 +76,15 @@ public interface WebDriver extends SearchContext { /** * The title of the current page. - * - * @return The title of the current page, - * with leading and trailing whitespace stripped, - * or null if one is not already set + * + * @return The title of the current page, with leading and trailing whitespace stripped, or null + * if one is not already set */ String getTitle(); /** * Find all elements within the current page using the given mechanism. - * + * * @param by The locating mechanism to use * @return A list of all {@link WebElement}s, or an empty list if nothing matches * @see org.openqa.selenium.By @@ -100,7 +94,7 @@ public interface WebDriver extends SearchContext { /** * Find the first {@link WebElement} using the given method. - * + * * @param by The locating mechanism * @return The first matching element on the current page * @throws NoSuchElementException If no matching elements are found @@ -110,22 +104,19 @@ public interface WebDriver extends SearchContext { // Misc /** - * Get the source of the last loaded page. If the page has been modified - * after loading (for example, by Javascript) there is no guarentee that the - * returned text is that of the modified page. Please consult the - * documentation of the particular driver being used to determine whether - * the returned text reflects the current state of the page or the text last - * sent by the web server. The page source returned is a representation of - * the underlying DOM: do not expect it to be formatted or escaped in the same - * way as the response sent from the web server. - * + * Get the source of the last loaded page. If the page has been modified after loading (for + * example, by Javascript) there is no guarentee that the returned text is that of the modified + * page. Please consult the documentation of the particular driver being used to determine whether + * the returned text reflects the current state of the page or the text last sent by the web + * server. The page source returned is a representation of the underlying DOM: do not expect it to + * be formatted or escaped in the same way as the response sent from the web server. + * * @return The source of the current page */ String getPageSource(); /** - * Close the current window, quitting the browser if it's the last window - * currently open. + * Close the current window, quitting the browser if it's the last window currently open. */ void close(); @@ -135,39 +126,39 @@ public interface WebDriver extends SearchContext { void quit(); /** - * Return a set of window handles which can be used to iterate over all open windows of - * this webdriver instance by passing them to {@link #switchTo().window(String)} - * + * Return a set of window handles which can be used to iterate over all open windows of this + * webdriver instance by passing them to {@link #switchTo().window(String)} + * * @return A set of window handles which can be used to iterate over all open windows. */ Set getWindowHandles(); /** - * Return an opaque handle to this window that uniquely identifies it within this driver - * instance. This can be used to switch to this window at a later date + * Return an opaque handle to this window that uniquely identifies it within this driver instance. + * This can be used to switch to this window at a later date */ String getWindowHandle(); /** * Send future commands to a different frame or window. - * + * * @return A TargetLocator which can be used to select a frame or window * @see org.openqa.selenium.WebDriver.TargetLocator */ TargetLocator switchTo(); /** - * An abstraction allowing the driver to access the browser's history and to - * navigate to a given URL. - * - * @return A {@link org.openqa.selenium.WebDriver.Navigation} that allows - * the selection of what to do next + * An abstraction allowing the driver to access the browser's history and to navigate to a given + * URL. + * + * @return A {@link org.openqa.selenium.WebDriver.Navigation} that allows the selection of what to + * do next */ Navigation navigate(); /** * Gets the Option interface - * + * * @return An option interface * @see org.openqa.selenium.WebDriver.Options */ @@ -179,26 +170,24 @@ public interface WebDriver extends SearchContext { interface Options { /** - * Add a specific cookie. If the cookie's domain name is left blank, it - * is assumed that the cookie is meant for the domain of the current - * document. - * + * Add a specific cookie. If the cookie's domain name is left blank, it is assumed that the + * cookie is meant for the domain of the current document. + * * @param cookie The cookie to add. */ void addCookie(Cookie cookie); /** - * Delete the named cookie from the current domain. This is equivalent - * to setting the named cookie's expiry date to some time in the past. - * + * Delete the named cookie from the current domain. This is equivalent to setting the named + * cookie's expiry date to some time in the past. + * * @param name The name of the cookie to delete */ void deleteCookieNamed(String name); /** - * Delete a cookie from the browser's "cookie jar". The domain of the - * cookie will be ignored. - * + * Delete a cookie from the browser's "cookie jar". The domain of the cookie will be ignored. + * * @param cookie */ void deleteCookie(Cookie cookie); @@ -209,16 +198,16 @@ interface Options { void deleteAllCookies(); /** - * Get all the cookies for the current domain. This is the equivalent of - * calling "document.cookie" and parsing the result - * + * Get all the cookies for the current domain. This is the equivalent of calling + * "document.cookie" and parsing the result + * * @return A Set of cookies for the current domain. */ Set getCookies(); /** * Get a cookie with a given name. - * + * * @param name the name of the cookie * @return the cookie, or null if no cookie with the given name is present */ @@ -230,8 +219,7 @@ interface Options { Timeouts timeouts(); /** - * Returns the interface for controlling IME engines to generate - * complex-script input. + * Returns the interface for controlling IME engines to generate complex-script input. */ ImeHandler ime(); } @@ -242,19 +230,17 @@ interface Options { interface Timeouts { /** - * Specifies the amount of time the driver should wait when searching for an - * element if it is not immediately present. + * Specifies the amount of time the driver should wait when searching for an element if it is + * not immediately present. *

- * When searching for a single element, the driver should poll the page - * until the element has been found, or this timeout expires before throwing - * a {@link NoSuchElementException}. When searching for multiple elements, - * the driver should poll the page until at least one element has been found - * or this timeout has expired. + * When searching for a single element, the driver should poll the page until the element has + * been found, or this timeout expires before throwing a {@link NoSuchElementException}. When + * searching for multiple elements, the driver should poll the page until at least one element + * has been found or this timeout has expired. *

- * Increasing the implicit wait timeout should be used judiciously as it - * will have an adverse effect on test run time, especially when used with - * slower location strategies like XPath. - * + * Increasing the implicit wait timeout should be used judiciously as it will have an adverse + * effect on test run time, especially when used with slower location strategies like XPath. + * * @param time The amount of time to wait. * @param unit The unit of measure for {@code time}. * @return A self reference. @@ -262,10 +248,10 @@ interface Timeouts { Timeouts implicitlyWait(long time, TimeUnit unit); /** - * Sets the amount of time to wait for an asynchronous script to finish - * execution before throwing an error. If the timeout is negative, then the - * script will be allowed to run indefinitely. - * + * Sets the amount of time to wait for an asynchronous script to finish execution before + * throwing an error. If the timeout is negative, then the script will be allowed to run + * indefinitely. + * * @param time The timeout value. * @param unit The unit of time. * @return A self reference. @@ -279,12 +265,11 @@ interface Timeouts { */ interface TargetLocator { /** - * Select a frame by its (zero-based) index. That is, if a page has - * three frames, the first frame would be at index "0", the second at - * index "1" and the third at index "2". Once the frame has been - * selected, all subsequent calls on the WebDriver interface are made to - * that frame. - * + * Select a frame by its (zero-based) index. That is, if a page has three frames, the first + * frame would be at index "0", the second at index "1" and the third at index "2". Once the + * frame has been selected, all subsequent calls on the WebDriver interface are made to that + * frame. + * * @param index (zero-based) index * @return This driver focused on the given frame * @throws NoSuchFrameException If the frame cannot be found @@ -292,11 +277,11 @@ interface TargetLocator { WebDriver frame(int index); /** - * Select a frame by its name or ID. Frames located by matching name - * attributes are always given precedence over those matched by ID. - * - * @param nameOrId the name of the frame window, the id of the - * <frame> or <iframe> element, or the (zero-based) index + * Select a frame by its name or ID. Frames located by matching name attributes are always given + * precedence over those matched by ID. + * + * @param nameOrId the name of the frame window, the id of the <frame> or <iframe> + * element, or the (zero-based) index * @return This driver focused on the given frame * @throws NoSuchFrameException If the frame cannot be found */ @@ -304,11 +289,10 @@ interface TargetLocator { /** * Select a frame using its previously located {@link WebElement}. - * + * * @param frameElement The frame element to switch to. * @return This driver focused on the given frame. - * @throws NoSuchFrameException If the given element is neither an IFRAME - * nor a FRAME element. + * @throws NoSuchFrameException If the given element is neither an IFRAME nor a FRAME element. * @throws StaleElementReferenceException If the WebElement has gone stale. * @see WebDriver#findElement(By) */ @@ -316,16 +300,18 @@ interface TargetLocator { /** * Switch the focus of future commands for this driver to the window with the given name/handle. - * - * @param nameOrHandle The name of the window or the handle as returned by {@link WebDriver#getWindowHandle()} + * + * @param nameOrHandle The name of the window or the handle as returned by + * {@link WebDriver#getWindowHandle()} * @return This driver focused on the given window * @throws NoSuchWindowException If the window cannot be found */ WebDriver window(String nameOrHandle); /** - * Selects either the first frame on the page, or the main document when a page contains iframes. - * + * Selects either the first frame on the page, or the main document when a page contains + * iframes. + * * @return This driver focused on the top window/first frame. */ WebDriver defaultContent(); @@ -334,14 +320,15 @@ interface TargetLocator { * Switches to the element that currently has focus within the document currently "switched to", * or the body element if this cannot be detected. This matches the semantics of calling * "document.activeElement" in Javascript. - * - * @return The WebElement with focus, or the body element if no element with focus can be detected. + * + * @return The WebElement with focus, or the body element if no element with focus can be + * detected. */ WebElement activeElement(); /** * Switches to the currently active modal dialog for this particular driver instance. - * + * * @return A handle to the dialog. */ Alert alert(); @@ -354,29 +341,27 @@ interface Navigation { void back(); /** - * Move a single "item" forward in the browser's history. Does nothing if - * we are on the latest page viewed. + * Move a single "item" forward in the browser's history. Does nothing if we are on the latest + * page viewed. */ void forward(); /** - * Load a new web page in the current browser window. This is done using an - * HTTP GET operation, and the method will block until the load is complete. - * This will follow redirects issued either by the server or as a - * meta-redirect from within the returned HTML. Should a meta-redirect - * "rest" for any duration of time, it is best to wait until this timeout is - * over, since should the underlying page change whilst your test is - * executing the results of future calls against this interface will be - * against the freshly loaded page. - * + * Load a new web page in the current browser window. This is done using an HTTP GET operation, + * and the method will block until the load is complete. This will follow redirects issued + * either by the server or as a meta-redirect from within the returned HTML. Should a + * meta-redirect "rest" for any duration of time, it is best to wait until this timeout is over, + * since should the underlying page change whilst your test is executing the results of future + * calls against this interface will be against the freshly loaded page. + * * @param url The URL to load. It is best to use a fully qualified URL */ void to(String url); /** * Overloaded version of {@link #to(String)} that makes it easy to pass in a URL. - * + * * @param url */ void to(URL url); @@ -393,6 +378,7 @@ interface Navigation { interface ImeHandler { /** * All available engines on the machine. To use an engine, it has to be activated. + * * @return list of available IME engines. * @throws ImeNotAvailableException if the host does not support IME. */ @@ -400,6 +386,7 @@ interface ImeHandler { /** * Get the name of the active IME engine. The name string is platform-specific. + * * @return name of the active IME engine. * @throws ImeNotAvailableException if the host does not support IME. */ @@ -407,6 +394,7 @@ interface ImeHandler { /** * Indicates whether IME input active at the moment (not if it's available). + * * @return true if IME input is available and currently active, false otherwise. * @throws ImeNotAvailableException if the host does not support IME. */ @@ -415,6 +403,7 @@ interface ImeHandler { /** * De-activate IME input (turns off the currently activated engine). Note that getActiveEngine * may still return the name of the engine but isActivated will return false. + * * @throws ImeNotAvailableException if the host does not support IME. */ void deactivate(); @@ -422,15 +411,15 @@ interface ImeHandler { /** * Make an engines that is available (appears on the list returned by getAvailableEngines) * active. After this call, the only loaded engine on the IME daemon will be this one and the - * input sent using sendKeys will be converted by the engine. - * Noteh that this is a platform-independent method of activating IME - * (the platform-specific way being using keyboard shortcuts). - - * + * input sent using sendKeys will be converted by the engine. Noteh that this is a + * platform-independent method of activating IME (the platform-specific way being using keyboard + * shortcuts). + * + * * @param engine name of engine to activate. * @throws ImeNotAvailableException if the host does not support IME. * @throws ImeActivationFailedException if the engine is not available or if activation failed - * for other reasons. + * for other reasons. */ void activateEngine(String engine); } From 30b7bd4b7424fa02f99db2b769ed54d2c41ddf5f Mon Sep 17 00:00:00 2001 From: Paul Hammant Date: Wed, 7 Sep 2011 17:33:46 +0000 Subject: [PATCH 080/114] paul hammant: Add Javadoc to describe the entanglement with implicit waits r13764 --- src/main/java/org/openqa/selenium/WebDriver.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index ec1e5e321..d67e34c2e 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -84,20 +84,32 @@ public interface WebDriver extends SearchContext { /** * Find all elements within the current page using the given mechanism. + * This method is affected by the 'implicit wait' times in force at the time of execution. + * For example, that is 5 seconds, the findElements(..) after its first attempt to collect + * matching WebElements if there is at least one. If there were no matching WebElements + * after the first attempt, then the method will wait in line with the interval specified, + * then try again. It will keep going until it finds at least one WebElement in a pass, + * or the configured timeout is reached. * * @param by The locating mechanism to use * @return A list of all {@link WebElement}s, or an empty list if nothing matches * @see org.openqa.selenium.By + * @see org.openqa.selenium.WebDriver.Timeouts */ List findElements(By by); /** * Find the first {@link WebElement} using the given method. + * This method is affected by the 'implicit wait' times in force at the time of execution. + * The findElement(..) invocation will return a matching row, or try again repeatedly until + * the configured timeout is reached. * * @param by The locating mechanism * @return The first matching element on the current page * @throws NoSuchElementException If no matching elements are found + * @see org.openqa.selenium.By + * @see org.openqa.selenium.WebDriver.Timeouts */ WebElement findElement(By by); From 7705dcf011279ea70b983fa9a18fec6c21adc2cf Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Fri, 9 Sep 2011 12:05:45 +0000 Subject: [PATCH 081/114] SimonStewart: Rewording some of the docs for findElements r13803 --- src/main/java/org/openqa/selenium/WebDriver.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index d67e34c2e..32d3ce73c 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -84,12 +84,9 @@ public interface WebDriver extends SearchContext { /** * Find all elements within the current page using the given mechanism. - * This method is affected by the 'implicit wait' times in force at the time of execution. - * For example, that is 5 seconds, the findElements(..) after its first attempt to collect - * matching WebElements if there is at least one. If there were no matching WebElements - * after the first attempt, then the method will wait in line with the interval specified, - * then try again. It will keep going until it finds at least one WebElement in a pass, - * or the configured timeout is reached. + * This method is affected by the 'implicit wait' times in force at the time of execution. When + * implicitly waiting, this method will return as soon as there are more than 0 items in the + * found collection, or will return an empty list if the timeout is reached. * * @param by The locating mechanism to use * @return A list of all {@link WebElement}s, or an empty list if nothing matches From e1bf9a5ab89c969e332363ee6cb74ad037aa61a8 Mon Sep 17 00:00:00 2001 From: Alexei Barantsev Date: Wed, 28 Sep 2011 07:42:32 +0000 Subject: [PATCH 082/114] AlexeiBarantsev: Adding @throws clause to switchTo().alert() r13980 --- src/main/java/org/openqa/selenium/WebDriver.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 32d3ce73c..74672d046 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -339,6 +339,7 @@ interface TargetLocator { * Switches to the currently active modal dialog for this particular driver instance. * * @return A handle to the dialog. + * @throws NoAlertPresentException If the dialog cannot be found */ Alert alert(); } From 604983fb63b21314a43ba7a380c124a1a8b3518a Mon Sep 17 00:00:00 2001 From: Paul Hammant Date: Wed, 12 Oct 2011 15:57:27 +0000 Subject: [PATCH 083/114] Paul Hammant: ThoughtWorks code grant to SFC completed r14136 --- src/main/java/org/openqa/selenium/WebDriver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 74672d046..39428978b 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -1,7 +1,7 @@ /* Copyright 2007-2009 WebDriver committers Copyright 2007-2009 Google Inc. -Portions copyright 2007 ThoughtWorks, Inc +Portions copyright 2011 Software Freedom Conservatory Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From d9bad6ce0033901b2484ed264af4d93bcfc8fb68 Mon Sep 17 00:00:00 2001 From: Jari Bakken Date: Mon, 7 Nov 2011 16:32:52 +0000 Subject: [PATCH 084/114] JariBakken: Beta implementation of window resize/move for Firefox + Ruby/Java. This adds two resources to the wire protocol: /session/:sessionId/window/:windowHandle/size /session/:sessionId/window/:windowHandle/position Both resources accept GET and POST requests to get and set the values. Update issue 174 Labels: -Browser-All Browser-IE Browser-Chrome Browser-HtmlUnit Browser-Opera Lang-CSharp Lang-Python Status: Started r14578 --- .../java/org/openqa/selenium/WebDriver.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 39428978b..64101db75 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -231,6 +231,12 @@ interface Options { * Returns the interface for controlling IME engines to generate complex-script input. */ ImeHandler ime(); + + /** + * Returns the interface for managing the current window. + */ + @Beta + Window window(); } /** @@ -433,4 +439,38 @@ interface ImeHandler { */ void activateEngine(String engine); } + + @Beta + interface Window { + /** + * Set the size of the current window. This will change the outer window dimension, + * not just the view port, synonymous to window.resizeTo() in JS. + * + * @param targetSize The target size. + */ + void setSize(Dimension targetSize); + + /** + * Set the position of the current window. This is relative to the upper left corner of the + * screen, synonymous to window.moveTo() in JS. + * + * @param targetPosition The target position of the window. + */ + void setPosition(Point targetPosition); + + /** + * Get the size of the current window. This will return the outer window dimension, not just + * the view port. + * + * @return The current window size. + */ + Dimension getSize(); + + /** + * Get the position of the current window, relative to the upper left corner of the screen. + * + * @return The current window position. + */ + Point getPosition(); + } } From 6e9e284439c387f43f2f5ddfbd4d3787015fe78d Mon Sep 17 00:00:00 2001 From: Kristian Rosenvold Date: Sat, 19 Nov 2011 10:43:13 +0000 Subject: [PATCH 085/114] KristianRosenvold: Added same javadoc in WebDriver too r14822 --- src/main/java/org/openqa/selenium/WebDriver.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 64101db75..8cfa22d50 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -101,7 +101,10 @@ public interface WebDriver extends SearchContext { * This method is affected by the 'implicit wait' times in force at the time of execution. * The findElement(..) invocation will return a matching row, or try again repeatedly until * the configured timeout is reached. - * + * + * findElement should not be used to look for non-present elements, use {@link #findElements(By)} + * and assert zero length response instead. + * * @param by The locating mechanism * @return The first matching element on the current page * @throws NoSuchElementException If no matching elements are found From 2cc491665dbe368f3231cb44887970e21c6cad54 Mon Sep 17 00:00:00 2001 From: Alexei Barantsev Date: Tue, 13 Dec 2011 19:07:08 +0000 Subject: [PATCH 086/114] AlexeiBarantsev: Implementing a separate implicit timeout for alerts. Added a new command to JsonWireProtocol. Implemented in FirefoxDriver, IEDriver and HtmlUnitDriver (and probably AndriodDriver). Implemented Java bindings for the new command. Default implicit timeout for alerts set to 2000ms. r15180 --- src/main/java/org/openqa/selenium/WebDriver.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 8cfa22d50..c2ab22bfe 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -265,6 +265,18 @@ interface Timeouts { */ Timeouts implicitlyWait(long time, TimeUnit unit); + /** + * Specifies the amount of time the driver should wait for the alert to appear. Default value is 2000ms. + *

+ * Increasing the implicit wait timeout should be used judiciously as it will have an adverse + * effect on test run time, especially when used to wait for a missing alert. + * + * @param time The amount of time to wait. + * @param unit The unit of measure for {@code time}. + * @return A self reference. + */ + Timeouts implicitlyWaitForAlerts(long time, TimeUnit unit); + /** * Sets the amount of time to wait for an asynchronous script to finish execution before * throwing an error. If the timeout is negative, then the script will be allowed to run From ed2035aea6f726ab4af9561d8c6bdb9b82ce3a66 Mon Sep 17 00:00:00 2001 From: Alexei Barantsev Date: Thu, 15 Dec 2011 14:02:42 +0000 Subject: [PATCH 087/114] AlexeiBarantsev: Reverting back r15180 r15185 --- src/main/java/org/openqa/selenium/WebDriver.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index c2ab22bfe..8cfa22d50 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -265,18 +265,6 @@ interface Timeouts { */ Timeouts implicitlyWait(long time, TimeUnit unit); - /** - * Specifies the amount of time the driver should wait for the alert to appear. Default value is 2000ms. - *

- * Increasing the implicit wait timeout should be used judiciously as it will have an adverse - * effect on test run time, especially when used to wait for a missing alert. - * - * @param time The amount of time to wait. - * @param unit The unit of measure for {@code time}. - * @return A self reference. - */ - Timeouts implicitlyWaitForAlerts(long time, TimeUnit unit); - /** * Sets the amount of time to wait for an asynchronous script to finish execution before * throwing an error. If the timeout is negative, then the script will be allowed to run From 3134cc4b50b7f9519387dcf852b8fcd788e15c3e Mon Sep 17 00:00:00 2001 From: Dounia Berrada Date: Thu, 15 Dec 2011 22:33:39 +0000 Subject: [PATCH 088/114] DouniaBerrad: Remote server logging and Android implementation of server logging. r15197 --- src/main/java/org/openqa/selenium/WebDriver.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 8cfa22d50..6b3ed68a0 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -18,6 +18,8 @@ package org.openqa.selenium; +import org.openqa.selenium.logging.Logs; + import java.net.URL; import java.util.List; import java.util.Set; @@ -240,6 +242,16 @@ interface Options { */ @Beta Window window(); + + /** + * Gets the {@link Logs} interface used to fetch different types of logs. + * + *

To set the logging preferences {@see LoggingPreferences}. + * + * @return A Logs interface. + */ + @Beta + Logs logs(); } /** From 6311f8509d335bc1a6672560f6ad29c89fb2e201 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Fri, 16 Dec 2011 13:19:25 +0000 Subject: [PATCH 089/114] DanielWagnerHall: s/Conservatory/Conservancy/g r15204 --- src/main/java/org/openqa/selenium/WebDriver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 6b3ed68a0..92f4d6e58 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -1,7 +1,7 @@ /* Copyright 2007-2009 WebDriver committers Copyright 2007-2009 Google Inc. -Portions copyright 2011 Software Freedom Conservatory +Portions copyright 2011 Software Freedom Conservancy Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 40c4f9f3f9f8dd68a6d3e1f1369a78a52173ad98 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Tue, 31 Jan 2012 12:04:39 +0000 Subject: [PATCH 090/114] SimonStewart: Minor fixes to the javadocs. No logical changes r15758 --- src/main/java/org/openqa/selenium/WebDriver.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 92f4d6e58..d33695603 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -119,11 +119,12 @@ public interface WebDriver extends SearchContext { /** * Get the source of the last loaded page. If the page has been modified after loading (for - * example, by Javascript) there is no guarentee that the returned text is that of the modified + * example, by Javascript) there is no guarantee that the returned text is that of the modified * page. Please consult the documentation of the particular driver being used to determine whether * the returned text reflects the current state of the page or the text last sent by the web * server. The page source returned is a representation of the underlying DOM: do not expect it to - * be formatted or escaped in the same way as the response sent from the web server. + * be formatted or escaped in the same way as the response sent from the web server. Think of it as + * an artist's impression. * * @return The source of the current page */ From 410a17b7ba719580a9aecf492644dfc37873e059 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 20 Feb 2012 17:28:01 +0000 Subject: [PATCH 091/114] SimonStewart: Implement the page loading timeout in the firefox driver r15926 --- src/main/java/org/openqa/selenium/WebDriver.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index d33695603..e3ab6b7cc 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -289,6 +289,16 @@ interface Timeouts { * @see JavascriptExecutor#executeAsyncScript(String, Object...) */ Timeouts setScriptTimeout(long time, TimeUnit unit); + + /** + * Sets the amount of time to wait for a page load to complete before throwing an error. + * If the timeout is negative, page loads can be indefinite. + * + * @param time The timeout value. + * @param unit The unit of time. + * @return + */ + Timeouts pageLoadTimeout(long time, TimeUnit unit); } /** From 6679c8b74a371dfc020d13e3cec30aee19635065 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Mon, 19 Mar 2012 01:57:47 +0000 Subject: [PATCH 092/114] DanielWagnerHall for ZacCampbell: Implementing window.maximise/restore for firefox. Update issue #3489 Patch applied r16287 --- src/main/java/org/openqa/selenium/WebDriver.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index e3ab6b7cc..82acac8a7 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -498,5 +498,15 @@ interface Window { * @return The current window position. */ Point getPosition(); + + /** + * Maximizes the current window if it is not already maximized + */ + void maximize(); + + /** + * Restores the current window if it is maximized + */ + void restore(); } } From c376fe1c3e3317d5f891b0565671deecf5a23115 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 19 Mar 2012 13:52:22 +0000 Subject: [PATCH 093/114] SimonStewart: the Window.restore method is not needed as it's effectively a call to setSize iff the window is maximized r16292 --- src/main/java/org/openqa/selenium/WebDriver.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 82acac8a7..da2849399 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -503,10 +503,5 @@ interface Window { * Maximizes the current window if it is not already maximized */ void maximize(); - - /** - * Restores the current window if it is maximized - */ - void restore(); } } From 88cc5ed57493d5fda07bdf46aa8203815af7848d Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 10:53:46 +0000 Subject: [PATCH 094/114] SimonStewart: After a code grant, the code is copyright the SFC and the selenium committers. Starting to update the copyright headers r16908 --- src/main/java/org/openqa/selenium/WebDriver.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index da2849399..a19ce186c 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -1,6 +1,5 @@ /* Copyright 2007-2009 WebDriver committers -Copyright 2007-2009 Google Inc. Portions copyright 2011 Software Freedom Conservancy Licensed under the Apache License, Version 2.0 (the "License"); From 4b5010df22b89ec6e5e3ac0f168b30ba90230e05 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 14:34:25 +0000 Subject: [PATCH 095/114] SimonStewart: Crassly pasting a copyright header on any file that didn't contain the string 'Copyright' that belongs to the project r16913 --- src/main/java/org/openqa/selenium/WebDriver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index a19ce186c..f04519828 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - */ +*/ package org.openqa.selenium; From 3988c0969516dd2fac72f369093bda9b6ce60ff2 Mon Sep 17 00:00:00 2001 From: Simon M Stewart Date: Mon, 14 May 2012 14:43:31 +0000 Subject: [PATCH 096/114] SimonStewart: We haven't been just the webdriver project for a long time. We are now the selenium project. No logical changes. r16915 --- src/main/java/org/openqa/selenium/WebDriver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index f04519828..52cf0fda9 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -1,5 +1,5 @@ /* -Copyright 2007-2009 WebDriver committers +Copyright 2007-2009 Selenium committers Portions copyright 2011 Software Freedom Conservancy Licensed under the Apache License, Version 2.0 (the "License"); From 38d48dd55966c741ab05f34e823d1326acd8ef86 Mon Sep 17 00:00:00 2001 From: Kristian Rosenvold Date: Fri, 11 Jan 2013 22:18:32 +0100 Subject: [PATCH 097/114] KristianRosenvold: Removed windows carriage returns From a5268652bbb7e1a6447c9bf98757d7a056980c54 Mon Sep 17 00:00:00 2001 From: Alexei Barantsev Date: Fri, 23 Aug 2013 23:53:32 +0400 Subject: [PATCH 098/114] Improving javadoc to correspond to the Specification --- src/main/java/org/openqa/selenium/WebDriver.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 52cf0fda9..0b4c33599 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -305,10 +305,10 @@ interface Timeouts { */ interface TargetLocator { /** - * Select a frame by its (zero-based) index. That is, if a page has three frames, the first - * frame would be at index "0", the second at index "1" and the third at index "2". Once the - * frame has been selected, all subsequent calls on the WebDriver interface are made to that - * frame. + * Select a frame by its (zero-based) index. Selecting a frame by index is equivalent to the + * JS expression window.frames[index] where "window" is the DOM window represented by the + * current context. Once the frame has been selected, all subsequent calls on the WebDriver + * interface are made to that frame. * * @param index (zero-based) index * @return This driver focused on the given frame From 9744f523f2aeb32c1f2f85bc4199356e7eec4bab Mon Sep 17 00:00:00 2001 From: Alexandr Savchuk Date: Tue, 1 Oct 2013 18:38:54 +0400 Subject: [PATCH 099/114] Fixes some server and client javadocs. Fixes issue #4290. --- src/main/java/org/openqa/selenium/WebDriver.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) mode change 100644 => 100755 src/main/java/org/openqa/selenium/WebDriver.java diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java old mode 100644 new mode 100755 index 0b4c33599..6a5871368 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -18,6 +18,7 @@ package org.openqa.selenium; import org.openqa.selenium.logging.Logs; +import org.openqa.selenium.logging.LoggingPreferences; import java.net.URL; import java.util.List; @@ -141,7 +142,7 @@ public interface WebDriver extends SearchContext { /** * Return a set of window handles which can be used to iterate over all open windows of this - * webdriver instance by passing them to {@link #switchTo().window(String)} + * WebDriver instance by passing them to {@link #switchTo()}.{@link Options#window()} * * @return A set of window handles which can be used to iterate over all open windows. */ @@ -246,7 +247,7 @@ interface Options { /** * Gets the {@link Logs} interface used to fetch different types of logs. * - *

To set the logging preferences {@see LoggingPreferences}. + *

To set the logging preferences {@link LoggingPreferences}. * * @return A Logs interface. */ @@ -295,7 +296,7 @@ interface Timeouts { * * @param time The timeout value. * @param unit The unit of time. - * @return + * @return A Timeouts interface. */ Timeouts pageLoadTimeout(long time, TimeUnit unit); } From 1b54c5181a5c0353e6ceba1fa7946d7fe3f84c6d Mon Sep 17 00:00:00 2001 From: Jason Leyba Date: Tue, 15 Oct 2013 15:33:25 -0700 Subject: [PATCH 100/114] Whitespace and import clean-up. --- src/main/java/org/openqa/selenium/WebDriver.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 src/main/java/org/openqa/selenium/WebDriver.java diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java old mode 100755 new mode 100644 From 5a4afd8af92f4cd49e59e1209e55d07198529128 Mon Sep 17 00:00:00 2001 From: Dominik Dary Date: Wed, 12 Mar 2014 16:58:43 +0100 Subject: [PATCH 101/114] Implementing support for switching context as described here: http://code.google.com/p/selenium/source/browse/spec-draft.md?repo=mobile#133 - this feature will be used by mobile WebDriver users to switch between different contexts like the native or the webview UI element tree - The feature is end to end tested with latest selendroid snapshot version (6a126ab3782deb7dd0cc99c6e3785c72d636959b) --- .../java/org/openqa/selenium/WebDriver.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 6a5871368..326a49efc 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -154,6 +154,20 @@ public interface WebDriver extends SearchContext { */ String getWindowHandle(); + /** + * Return a set of context handles which can be used to iterate over all contexts of this + * WebDriver instance + * + * @return A set of context handles which can be used to iterate over available contexts. + */ + Set getContextHandles(); + + /** + * Return an opaque handle to this context that uniquely identifies it within this driver instance. + * This can be used to switch to this context at a later date + */ + String getContext(); + /** * Send future commands to a different frame or window. * @@ -374,6 +388,17 @@ interface TargetLocator { * @throws NoAlertPresentException If the dialog cannot be found */ Alert alert(); + + /** + * Switch the focus of future commands for this driver to the context with the given name. + * + * @param name The name of the context as returned by + * {@link WebDriver#getContexts()} + * @return This driver focused on the given window + * @throws NoSuchContextException If the context cannot be found + */ + WebDriver context(String name); + } interface Navigation { From d7c31b04e95c6d99c7bd9d208e84671077ea83b5 Mon Sep 17 00:00:00 2001 From: Alexei Barantsev Date: Wed, 12 Mar 2014 23:54:21 +0400 Subject: [PATCH 102/114] Fixing javadoc --- src/main/java/org/openqa/selenium/WebDriver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 326a49efc..0c522d269 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -393,7 +393,7 @@ interface TargetLocator { * Switch the focus of future commands for this driver to the context with the given name. * * @param name The name of the context as returned by - * {@link WebDriver#getContexts()} + * {@link WebDriver#getContextHandles()} * @return This driver focused on the given window * @throws NoSuchContextException If the context cannot be found */ From adb675341e31e375fe865fbd2dc8db1e93e47681 Mon Sep 17 00:00:00 2001 From: Alexei Barantsev Date: Thu, 13 Mar 2014 00:15:57 +0400 Subject: [PATCH 103/114] Adding swicthToParentFrame to Java API --- src/main/java/org/openqa/selenium/WebDriver.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 0c522d269..85fb6b159 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -353,6 +353,14 @@ interface TargetLocator { */ WebDriver frame(WebElement frameElement); + /** + * Change focus to the parent context. If the current context is the top level browsing context, + * the context remains unchanged. + * + * @return This driver focused on the parent frame + */ + WebDriver parentFrame(); + /** * Switch the focus of future commands for this driver to the window with the given name/handle. * From 250b559844a6add5e21b36953ccc04d714f1f0b6 Mon Sep 17 00:00:00 2001 From: Simon Stewart Date: Mon, 17 Mar 2014 14:59:22 +0000 Subject: [PATCH 104/114] Push context switching into a role-based interface. Subclasses of RemoteWEbDriver that need this should extend TargetLocator and use covariant return types to keep everything happy and sweet. --- .../java/org/openqa/selenium/WebDriver.java | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 85fb6b159..f0c41be47 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -154,20 +154,6 @@ public interface WebDriver extends SearchContext { */ String getWindowHandle(); - /** - * Return a set of context handles which can be used to iterate over all contexts of this - * WebDriver instance - * - * @return A set of context handles which can be used to iterate over available contexts. - */ - Set getContextHandles(); - - /** - * Return an opaque handle to this context that uniquely identifies it within this driver instance. - * This can be used to switch to this context at a later date - */ - String getContext(); - /** * Send future commands to a different frame or window. * @@ -396,17 +382,6 @@ interface TargetLocator { * @throws NoAlertPresentException If the dialog cannot be found */ Alert alert(); - - /** - * Switch the focus of future commands for this driver to the context with the given name. - * - * @param name The name of the context as returned by - * {@link WebDriver#getContextHandles()} - * @return This driver focused on the given window - * @throws NoSuchContextException If the context cannot be found - */ - WebDriver context(String name); - } interface Navigation { From e76a2269c2ff0a5e51ed301be97f7e7bbbe481c8 Mon Sep 17 00:00:00 2001 From: Luke Inman-Semerau Date: Thu, 26 Feb 2015 15:44:48 -0800 Subject: [PATCH 105/114] updating javadocs / fixing javadoc errors built using java 8 --- src/main/java/org/openqa/selenium/WebDriver.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index f0c41be47..3ec01ffc7 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -29,22 +29,22 @@ /** * The main interface to use for testing, which represents an idealised web browser. The methods in * this class fall into three categories: - *

+ *

*

    *
  • Control of the browser itself
  • *
  • Selection of {@link WebElement}s
  • *
  • Debugging aids
  • *
- *

+ *

* Key methods are {@link WebDriver#get(String)}, which is used to load a new web page, and the * various methods similar to {@link WebDriver#findElement(By)}, which is used to find * {@link WebElement}s. - *

+ *

* Currently, you will need to instantiate implementations of this class directly. It is hoped that * you write your tests against this interface so that you may "swap in" a more fully featured * browser when there is a requirement for one. Given this approach to testing, it is best to start * writing your tests using the {@link org.openqa.selenium.htmlunit.HtmlUnitDriver} implementation. - *

+ *

* Note that all methods that use XPath to locate elements will throw a {@link RuntimeException} * should there be an error thrown by the underlying XPath engine. * @@ -263,12 +263,12 @@ interface Timeouts { /** * Specifies the amount of time the driver should wait when searching for an element if it is * not immediately present. - *

+ *

* When searching for a single element, the driver should poll the page until the element has * been found, or this timeout expires before throwing a {@link NoSuchElementException}. When * searching for multiple elements, the driver should poll the page until at least one element * has been found or this timeout has expired. - *

+ *

* Increasing the implicit wait timeout should be used judiciously as it will have an adverse * effect on test run time, especially when used with slower location strategies like XPath. * From 0758702e2bd929fd50e1ac642d2d7a4ef4e71335 Mon Sep 17 00:00:00 2001 From: Jason Leyba Date: Sat, 4 Apr 2015 18:34:01 -0700 Subject: [PATCH 106/114] For #401, apply a consistent copyright notice to the java/ tree. Uses a line-comment format rather than block comments for consistency across languages. --- .../java/org/openqa/selenium/WebDriver.java | 98 +++++++++---------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 3ec01ffc7..8df863dc0 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -1,19 +1,19 @@ -/* -Copyright 2007-2009 Selenium committers -Portions copyright 2011 Software Freedom Conservancy - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ +// Licensed to the Software Freedom Conservancy (SFC) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The SFC licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. package org.openqa.selenium; @@ -47,7 +47,7 @@ *

* Note that all methods that use XPath to locate elements will throw a {@link RuntimeException} * should there be an error thrown by the underlying XPath engine. - * + * * @see org.openqa.selenium.ie.InternetExplorerDriver * @see org.openqa.selenium.htmlunit.HtmlUnitDriver */ @@ -62,14 +62,14 @@ public interface WebDriver extends SearchContext { * the underlying page change whilst your test is executing the results of future calls against * this interface will be against the freshly loaded page. Synonym for * {@link org.openqa.selenium.WebDriver.Navigation#to(String)}. - * + * * @param url The URL to load. It is best to use a fully qualified URL */ void get(String url); /** * Get a string representing the current URL that the browser is looking at. - * + * * @return The URL of the page currently loaded in the browser */ String getCurrentUrl(); @@ -78,7 +78,7 @@ public interface WebDriver extends SearchContext { /** * The title of the current page. - * + * * @return The title of the current page, with leading and trailing whitespace stripped, or null * if one is not already set */ @@ -89,7 +89,7 @@ public interface WebDriver extends SearchContext { * This method is affected by the 'implicit wait' times in force at the time of execution. When * implicitly waiting, this method will return as soon as there are more than 0 items in the * found collection, or will return an empty list if the timeout is reached. - * + * * @param by The locating mechanism to use * @return A list of all {@link WebElement}s, or an empty list if nothing matches * @see org.openqa.selenium.By @@ -101,7 +101,7 @@ public interface WebDriver extends SearchContext { /** * Find the first {@link WebElement} using the given method. * This method is affected by the 'implicit wait' times in force at the time of execution. - * The findElement(..) invocation will return a matching row, or try again repeatedly until + * The findElement(..) invocation will return a matching row, or try again repeatedly until * the configured timeout is reached. * * findElement should not be used to look for non-present elements, use {@link #findElements(By)} @@ -125,7 +125,7 @@ public interface WebDriver extends SearchContext { * server. The page source returned is a representation of the underlying DOM: do not expect it to * be formatted or escaped in the same way as the response sent from the web server. Think of it as * an artist's impression. - * + * * @return The source of the current page */ String getPageSource(); @@ -143,7 +143,7 @@ public interface WebDriver extends SearchContext { /** * Return a set of window handles which can be used to iterate over all open windows of this * WebDriver instance by passing them to {@link #switchTo()}.{@link Options#window()} - * + * * @return A set of window handles which can be used to iterate over all open windows. */ Set getWindowHandles(); @@ -156,7 +156,7 @@ public interface WebDriver extends SearchContext { /** * Send future commands to a different frame or window. - * + * * @return A TargetLocator which can be used to select a frame or window * @see org.openqa.selenium.WebDriver.TargetLocator */ @@ -165,7 +165,7 @@ public interface WebDriver extends SearchContext { /** * An abstraction allowing the driver to access the browser's history and to navigate to a given * URL. - * + * * @return A {@link org.openqa.selenium.WebDriver.Navigation} that allows the selection of what to * do next */ @@ -173,7 +173,7 @@ public interface WebDriver extends SearchContext { /** * Gets the Option interface - * + * * @return An option interface * @see org.openqa.selenium.WebDriver.Options */ @@ -187,7 +187,7 @@ interface Options { /** * Add a specific cookie. If the cookie's domain name is left blank, it is assumed that the * cookie is meant for the domain of the current document. - * + * * @param cookie The cookie to add. */ void addCookie(Cookie cookie); @@ -195,14 +195,14 @@ interface Options { /** * Delete the named cookie from the current domain. This is equivalent to setting the named * cookie's expiry date to some time in the past. - * + * * @param name The name of the cookie to delete */ void deleteCookieNamed(String name); /** * Delete a cookie from the browser's "cookie jar". The domain of the cookie will be ignored. - * + * * @param cookie */ void deleteCookie(Cookie cookie); @@ -215,14 +215,14 @@ interface Options { /** * Get all the cookies for the current domain. This is the equivalent of calling * "document.cookie" and parsing the result - * + * * @return A Set of cookies for the current domain. */ Set getCookies(); /** * Get a cookie with a given name. - * + * * @param name the name of the cookie * @return the cookie, or null if no cookie with the given name is present */ @@ -271,7 +271,7 @@ interface Timeouts { *

* Increasing the implicit wait timeout should be used judiciously as it will have an adverse * effect on test run time, especially when used with slower location strategies like XPath. - * + * * @param time The amount of time to wait. * @param unit The unit of measure for {@code time}. * @return A self reference. @@ -282,7 +282,7 @@ interface Timeouts { * Sets the amount of time to wait for an asynchronous script to finish execution before * throwing an error. If the timeout is negative, then the script will be allowed to run * indefinitely. - * + * * @param time The timeout value. * @param unit The unit of time. * @return A self reference. @@ -310,7 +310,7 @@ interface TargetLocator { * JS expression window.frames[index] where "window" is the DOM window represented by the * current context. Once the frame has been selected, all subsequent calls on the WebDriver * interface are made to that frame. - * + * * @param index (zero-based) index * @return This driver focused on the given frame * @throws NoSuchFrameException If the frame cannot be found @@ -320,7 +320,7 @@ interface TargetLocator { /** * Select a frame by its name or ID. Frames located by matching name attributes are always given * precedence over those matched by ID. - * + * * @param nameOrId the name of the frame window, the id of the <frame> or <iframe> * element, or the (zero-based) index * @return This driver focused on the given frame @@ -330,7 +330,7 @@ interface TargetLocator { /** * Select a frame using its previously located {@link WebElement}. - * + * * @param frameElement The frame element to switch to. * @return This driver focused on the given frame. * @throws NoSuchFrameException If the given element is neither an IFRAME nor a FRAME element. @@ -349,7 +349,7 @@ interface TargetLocator { /** * Switch the focus of future commands for this driver to the window with the given name/handle. - * + * * @param nameOrHandle The name of the window or the handle as returned by * {@link WebDriver#getWindowHandle()} * @return This driver focused on the given window @@ -360,7 +360,7 @@ interface TargetLocator { /** * Selects either the first frame on the page, or the main document when a page contains * iframes. - * + * * @return This driver focused on the top window/first frame. */ WebDriver defaultContent(); @@ -369,7 +369,7 @@ interface TargetLocator { * Switches to the element that currently has focus within the document currently "switched to", * or the body element if this cannot be detected. This matches the semantics of calling * "document.activeElement" in Javascript. - * + * * @return The WebElement with focus, or the body element if no element with focus can be * detected. */ @@ -377,7 +377,7 @@ interface TargetLocator { /** * Switches to the currently active modal dialog for this particular driver instance. - * + * * @return A handle to the dialog. * @throws NoAlertPresentException If the dialog cannot be found */ @@ -404,14 +404,14 @@ interface Navigation { * meta-redirect "rest" for any duration of time, it is best to wait until this timeout is over, * since should the underlying page change whilst your test is executing the results of future * calls against this interface will be against the freshly loaded page. - * + * * @param url The URL to load. It is best to use a fully qualified URL */ void to(String url); /** * Overloaded version of {@link #to(String)} that makes it easy to pass in a URL. - * + * * @param url */ void to(URL url); @@ -428,7 +428,7 @@ interface Navigation { interface ImeHandler { /** * All available engines on the machine. To use an engine, it has to be activated. - * + * * @return list of available IME engines. * @throws ImeNotAvailableException if the host does not support IME. */ @@ -436,7 +436,7 @@ interface ImeHandler { /** * Get the name of the active IME engine. The name string is platform-specific. - * + * * @return name of the active IME engine. * @throws ImeNotAvailableException if the host does not support IME. */ @@ -444,7 +444,7 @@ interface ImeHandler { /** * Indicates whether IME input active at the moment (not if it's available). - * + * * @return true if IME input is available and currently active, false otherwise. * @throws ImeNotAvailableException if the host does not support IME. */ @@ -453,7 +453,7 @@ interface ImeHandler { /** * De-activate IME input (turns off the currently activated engine). Note that getActiveEngine * may still return the name of the engine but isActivated will return false. - * + * * @throws ImeNotAvailableException if the host does not support IME. */ void deactivate(); @@ -464,8 +464,8 @@ interface ImeHandler { * input sent using sendKeys will be converted by the engine. Noteh that this is a * platform-independent method of activating IME (the platform-specific way being using keyboard * shortcuts). - * - * + * + * * @param engine name of engine to activate. * @throws ImeNotAvailableException if the host does not support IME. * @throws ImeActivationFailedException if the engine is not available or if activation failed From 94c146c6d91444f549bc8f9246a37c2ae0d021f9 Mon Sep 17 00:00:00 2001 From: Luke Inman-Semerau Date: Thu, 24 Sep 2015 15:19:42 -0700 Subject: [PATCH 107/114] first pass at fixing some of the javadoc errors... still quite a few to go --- src/main/java/org/openqa/selenium/WebDriver.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 8df863dc0..3d6003d57 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -29,7 +29,6 @@ /** * The main interface to use for testing, which represents an idealised web browser. The methods in * this class fall into three categories: - *

*

    *
  • Control of the browser itself
  • *
  • Selection of {@link WebElement}s
  • @@ -151,6 +150,8 @@ public interface WebDriver extends SearchContext { /** * Return an opaque handle to this window that uniquely identifies it within this driver instance. * This can be used to switch to this window at a later date + * + * @return the current window handle */ String getWindowHandle(); @@ -203,7 +204,7 @@ interface Options { /** * Delete a cookie from the browser's "cookie jar". The domain of the cookie will be ignored. * - * @param cookie + * @param cookie nom nom nom */ void deleteCookie(Cookie cookie); @@ -229,17 +230,17 @@ interface Options { Cookie getCookieNamed(String name); /** - * Returns the interface for managing driver timeouts. + * @return the interface for managing driver timeouts. */ Timeouts timeouts(); /** - * Returns the interface for controlling IME engines to generate complex-script input. + * @return the interface for controlling IME engines to generate complex-script input. */ ImeHandler ime(); /** - * Returns the interface for managing the current window. + * @return the interface for managing the current window. */ @Beta Window window(); @@ -412,7 +413,7 @@ interface Navigation { /** * Overloaded version of {@link #to(String)} that makes it easy to pass in a URL. * - * @param url + * @param url URL */ void to(URL url); From 0d1432c967540a577fc166f338cb25159f28a327 Mon Sep 17 00:00:00 2001 From: Luke Inman-Semerau Date: Sat, 26 Sep 2015 22:12:19 -0700 Subject: [PATCH 108/114] moar javadoc --- src/main/java/org/openqa/selenium/WebDriver.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 3d6003d57..324ca86f1 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -41,14 +41,10 @@ *

    * Currently, you will need to instantiate implementations of this class directly. It is hoped that * you write your tests against this interface so that you may "swap in" a more fully featured - * browser when there is a requirement for one. Given this approach to testing, it is best to start - * writing your tests using the {@link org.openqa.selenium.htmlunit.HtmlUnitDriver} implementation. + * browser when there is a requirement for one. *

    * Note that all methods that use XPath to locate elements will throw a {@link RuntimeException} * should there be an error thrown by the underlying XPath engine. - * - * @see org.openqa.selenium.ie.InternetExplorerDriver - * @see org.openqa.selenium.htmlunit.HtmlUnitDriver */ public interface WebDriver extends SearchContext { // Navigation From 517313e4f71974359222b28ff97afed8b54e75c1 Mon Sep 17 00:00:00 2001 From: Luke Inman-Semerau Date: Thu, 12 Nov 2015 11:34:59 -0800 Subject: [PATCH 109/114] adding selenium server pass throughs for W3C dialect of alert / window / cookie commands. changing how W3C dialect is detected by checking if 'status' is sent in the new session response switch to window in w3c passes in 'handle' variable instead of 'name' Fixes #1242 Fixes #1241 Fixes #1240 Fixes #1238 Fixes #1237 --- src/main/java/org/openqa/selenium/WebDriver.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 324ca86f1..5f0320890 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -238,7 +238,6 @@ interface Options { /** * @return the interface for managing the current window. */ - @Beta Window window(); /** @@ -508,5 +507,10 @@ interface Window { * Maximizes the current window if it is not already maximized */ void maximize(); + + /** + * Fullscreen the current window if it is not already fullscreen + */ + void fullscreen(); } } From 8f5f2a0ecb5d1a5117df4380ccc0431d03395255 Mon Sep 17 00:00:00 2001 From: TikhomirovSergey Date: Mon, 6 Jun 2016 20:28:37 +0300 Subject: [PATCH 110/114] New added code was formatted. Check style rules were changed --- google-style.xml | 7 +- .../org/openqa/selenium/SearchContext.java | 32 +- .../java/org/openqa/selenium/WebDriver.java | 823 +++++++++--------- .../java/org/openqa/selenium/WebElement.java | 374 ++++---- .../selenium/internal/FindsByClassName.java | 4 +- .../selenium/internal/FindsByCssSelector.java | 4 +- .../openqa/selenium/internal/FindsById.java | 4 +- .../selenium/internal/FindsByLinkText.java | 8 +- .../openqa/selenium/internal/FindsByName.java | 4 +- .../selenium/internal/FindsByTagName.java | 4 +- .../selenium/internal/FindsByXPath.java | 4 +- 11 files changed, 635 insertions(+), 633 deletions(-) diff --git a/google-style.xml b/google-style.xml index 13557abdd..dd40c8a90 100755 --- a/google-style.xml +++ b/google-style.xml @@ -42,7 +42,7 @@ - + @@ -181,9 +181,12 @@ - + + + + diff --git a/src/main/java/org/openqa/selenium/SearchContext.java b/src/main/java/org/openqa/selenium/SearchContext.java index 5aae99f45..b8b484e36 100644 --- a/src/main/java/org/openqa/selenium/SearchContext.java +++ b/src/main/java/org/openqa/selenium/SearchContext.java @@ -20,22 +20,22 @@ import java.util.List; public interface SearchContext { - /** - * Find all elements within the current context using the given mechanism. - * - * @param by The locating mechanism to use - * @return A list of all {@link WebElement}s, or an empty list if nothing matches - * @see org.openqa.selenium.By - */ - List findElements(By by); + /** + * Find all elements within the current context using the given mechanism. + * + * @param by The locating mechanism to use + * @return A list of all {@link WebElement}s, or an empty list if nothing matches + * @see org.openqa.selenium.By + */ + List findElements(By by); - /** - * Find the first {@link WebElement} using the given method. - * - * @param by The locating mechanism - * @return The first matching element on the current context - * @throws NoSuchElementException If no matching elements are found - */ - WebElement findElement(By by); + /** + * Find the first {@link WebElement} using the given method. + * + * @param by The locating mechanism + * @return The first matching element on the current context + * @throws NoSuchElementException If no matching elements are found + */ + WebElement findElement(By by); } diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index 5f0320890..e73d2df49 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -47,470 +47,469 @@ * should there be an error thrown by the underlying XPath engine. */ public interface WebDriver extends SearchContext { - // Navigation - - /** - * Load a new web page in the current browser window. This is done using an HTTP GET operation, - * and the method will block until the load is complete. This will follow redirects issued either - * by the server or as a meta-redirect from within the returned HTML. Should a meta-redirect - * "rest" for any duration of time, it is best to wait until this timeout is over, since should - * the underlying page change whilst your test is executing the results of future calls against - * this interface will be against the freshly loaded page. Synonym for - * {@link org.openqa.selenium.WebDriver.Navigation#to(String)}. - * - * @param url The URL to load. It is best to use a fully qualified URL - */ - void get(String url); - - /** - * Get a string representing the current URL that the browser is looking at. - * - * @return The URL of the page currently loaded in the browser - */ - String getCurrentUrl(); - - // General properties - - /** - * The title of the current page. - * - * @return The title of the current page, with leading and trailing whitespace stripped, or null - * if one is not already set - */ - String getTitle(); - - /** - * Find all elements within the current page using the given mechanism. - * This method is affected by the 'implicit wait' times in force at the time of execution. When - * implicitly waiting, this method will return as soon as there are more than 0 items in the - * found collection, or will return an empty list if the timeout is reached. - * - * @param by The locating mechanism to use - * @return A list of all {@link WebElement}s, or an empty list if nothing matches - * @see org.openqa.selenium.By - * @see org.openqa.selenium.WebDriver.Timeouts - */ - List findElements(By by); - - - /** - * Find the first {@link WebElement} using the given method. - * This method is affected by the 'implicit wait' times in force at the time of execution. - * The findElement(..) invocation will return a matching row, or try again repeatedly until - * the configured timeout is reached. - * - * findElement should not be used to look for non-present elements, use {@link #findElements(By)} - * and assert zero length response instead. - * - * @param by The locating mechanism - * @return The first matching element on the current page - * @throws NoSuchElementException If no matching elements are found - * @see org.openqa.selenium.By - * @see org.openqa.selenium.WebDriver.Timeouts - */ - WebElement findElement(By by); - - // Misc - - /** - * Get the source of the last loaded page. If the page has been modified after loading (for - * example, by Javascript) there is no guarantee that the returned text is that of the modified - * page. Please consult the documentation of the particular driver being used to determine whether - * the returned text reflects the current state of the page or the text last sent by the web - * server. The page source returned is a representation of the underlying DOM: do not expect it to - * be formatted or escaped in the same way as the response sent from the web server. Think of it as - * an artist's impression. - * - * @return The source of the current page - */ - String getPageSource(); - - /** - * Close the current window, quitting the browser if it's the last window currently open. - */ - void close(); - - /** - * Quits this driver, closing every associated window. - */ - void quit(); - - /** - * Return a set of window handles which can be used to iterate over all open windows of this - * WebDriver instance by passing them to {@link #switchTo()}.{@link Options#window()} - * - * @return A set of window handles which can be used to iterate over all open windows. - */ - Set getWindowHandles(); - - /** - * Return an opaque handle to this window that uniquely identifies it within this driver instance. - * This can be used to switch to this window at a later date - * - * @return the current window handle - */ - String getWindowHandle(); - - /** - * Send future commands to a different frame or window. - * - * @return A TargetLocator which can be used to select a frame or window - * @see org.openqa.selenium.WebDriver.TargetLocator - */ - TargetLocator switchTo(); - - /** - * An abstraction allowing the driver to access the browser's history and to navigate to a given - * URL. - * - * @return A {@link org.openqa.selenium.WebDriver.Navigation} that allows the selection of what to - * do next - */ - Navigation navigate(); - - /** - * Gets the Option interface - * - * @return An option interface - * @see org.openqa.selenium.WebDriver.Options - */ - Options manage(); - - /** - * An interface for managing stuff you would do in a browser menu - */ - interface Options { + // Navigation /** - * Add a specific cookie. If the cookie's domain name is left blank, it is assumed that the - * cookie is meant for the domain of the current document. + * Load a new web page in the current browser window. This is done using an HTTP GET operation, + * and the method will block until the load is complete. This will follow redirects issued either + * by the server or as a meta-redirect from within the returned HTML. Should a meta-redirect + * "rest" for any duration of time, it is best to wait until this timeout is over, since should + * the underlying page change whilst your test is executing the results of future calls against + * this interface will be against the freshly loaded page. Synonym for + * {@link org.openqa.selenium.WebDriver.Navigation#to(String)}. * - * @param cookie The cookie to add. + * @param url The URL to load. It is best to use a fully qualified URL */ - void addCookie(Cookie cookie); + void get(String url); /** - * Delete the named cookie from the current domain. This is equivalent to setting the named - * cookie's expiry date to some time in the past. + * Get a string representing the current URL that the browser is looking at. * - * @param name The name of the cookie to delete + * @return The URL of the page currently loaded in the browser */ - void deleteCookieNamed(String name); + String getCurrentUrl(); - /** - * Delete a cookie from the browser's "cookie jar". The domain of the cookie will be ignored. - * - * @param cookie nom nom nom - */ - void deleteCookie(Cookie cookie); + // General properties /** - * Delete all the cookies for the current domain. - */ - void deleteAllCookies(); - - /** - * Get all the cookies for the current domain. This is the equivalent of calling - * "document.cookie" and parsing the result + * The title of the current page. * - * @return A Set of cookies for the current domain. + * @return The title of the current page, with leading and trailing whitespace stripped, or null + * if one is not already set */ - Set getCookies(); + String getTitle(); /** - * Get a cookie with a given name. + * Find all elements within the current page using the given mechanism. + * This method is affected by the 'implicit wait' times in force at the time of execution. When + * implicitly waiting, this method will return as soon as there are more than 0 items in the + * found collection, or will return an empty list if the timeout is reached. * - * @param name the name of the cookie - * @return the cookie, or null if no cookie with the given name is present - */ - Cookie getCookieNamed(String name); - - /** - * @return the interface for managing driver timeouts. + * @param by The locating mechanism to use + * @return A list of all {@link WebElement}s, or an empty list if nothing matches + * @see org.openqa.selenium.By + * @see org.openqa.selenium.WebDriver.Timeouts */ - Timeouts timeouts(); + List findElements(By by); - /** - * @return the interface for controlling IME engines to generate complex-script input. - */ - ImeHandler ime(); /** - * @return the interface for managing the current window. - */ - Window window(); - - /** - * Gets the {@link Logs} interface used to fetch different types of logs. - * - *

    To set the logging preferences {@link LoggingPreferences}. - * - * @return A Logs interface. - */ - @Beta - Logs logs(); - } - - /** - * An interface for managing timeout behavior for WebDriver instances. - */ - interface Timeouts { - - /** - * Specifies the amount of time the driver should wait when searching for an element if it is - * not immediately present. - *

    - * When searching for a single element, the driver should poll the page until the element has - * been found, or this timeout expires before throwing a {@link NoSuchElementException}. When - * searching for multiple elements, the driver should poll the page until at least one element - * has been found or this timeout has expired. + * Find the first {@link WebElement} using the given method. + * This method is affected by the 'implicit wait' times in force at the time of execution. + * The findElement(..) invocation will return a matching row, or try again repeatedly until + * the configured timeout is reached. *

    - * Increasing the implicit wait timeout should be used judiciously as it will have an adverse - * effect on test run time, especially when used with slower location strategies like XPath. + * findElement should not be used to look for non-present elements, use {@link #findElements(By)} + * and assert zero length response instead. * - * @param time The amount of time to wait. - * @param unit The unit of measure for {@code time}. - * @return A self reference. + * @param by The locating mechanism + * @return The first matching element on the current page + * @throws NoSuchElementException If no matching elements are found + * @see org.openqa.selenium.By + * @see org.openqa.selenium.WebDriver.Timeouts */ - Timeouts implicitlyWait(long time, TimeUnit unit); + WebElement findElement(By by); - /** - * Sets the amount of time to wait for an asynchronous script to finish execution before - * throwing an error. If the timeout is negative, then the script will be allowed to run - * indefinitely. - * - * @param time The timeout value. - * @param unit The unit of time. - * @return A self reference. - * @see JavascriptExecutor#executeAsyncScript(String, Object...) - */ - Timeouts setScriptTimeout(long time, TimeUnit unit); - - /** - * Sets the amount of time to wait for a page load to complete before throwing an error. - * If the timeout is negative, page loads can be indefinite. - * - * @param time The timeout value. - * @param unit The unit of time. - * @return A Timeouts interface. - */ - Timeouts pageLoadTimeout(long time, TimeUnit unit); - } + // Misc - /** - * Used to locate a given frame or window. - */ - interface TargetLocator { /** - * Select a frame by its (zero-based) index. Selecting a frame by index is equivalent to the - * JS expression window.frames[index] where "window" is the DOM window represented by the - * current context. Once the frame has been selected, all subsequent calls on the WebDriver - * interface are made to that frame. + * Get the source of the last loaded page. If the page has been modified after loading (for + * example, by Javascript) there is no guarantee that the returned text is that of the modified + * page. Please consult the documentation of the particular driver being used to determine whether + * the returned text reflects the current state of the page or the text last sent by the web + * server. The page source returned is a representation of the underlying DOM: do not expect it to + * be formatted or escaped in the same way as the response sent from the web server. Think of it as + * an artist's impression. * - * @param index (zero-based) index - * @return This driver focused on the given frame - * @throws NoSuchFrameException If the frame cannot be found + * @return The source of the current page */ - WebDriver frame(int index); + String getPageSource(); /** - * Select a frame by its name or ID. Frames located by matching name attributes are always given - * precedence over those matched by ID. - * - * @param nameOrId the name of the frame window, the id of the <frame> or <iframe> - * element, or the (zero-based) index - * @return This driver focused on the given frame - * @throws NoSuchFrameException If the frame cannot be found - */ - WebDriver frame(String nameOrId); - - /** - * Select a frame using its previously located {@link WebElement}. - * - * @param frameElement The frame element to switch to. - * @return This driver focused on the given frame. - * @throws NoSuchFrameException If the given element is neither an IFRAME nor a FRAME element. - * @throws StaleElementReferenceException If the WebElement has gone stale. - * @see WebDriver#findElement(By) + * Close the current window, quitting the browser if it's the last window currently open. */ - WebDriver frame(WebElement frameElement); + void close(); /** - * Change focus to the parent context. If the current context is the top level browsing context, - * the context remains unchanged. - * - * @return This driver focused on the parent frame + * Quits this driver, closing every associated window. */ - WebDriver parentFrame(); + void quit(); /** - * Switch the focus of future commands for this driver to the window with the given name/handle. + * Return a set of window handles which can be used to iterate over all open windows of this + * WebDriver instance by passing them to {@link #switchTo()}.{@link Options#window()} * - * @param nameOrHandle The name of the window or the handle as returned by - * {@link WebDriver#getWindowHandle()} - * @return This driver focused on the given window - * @throws NoSuchWindowException If the window cannot be found + * @return A set of window handles which can be used to iterate over all open windows. */ - WebDriver window(String nameOrHandle); + Set getWindowHandles(); /** - * Selects either the first frame on the page, or the main document when a page contains - * iframes. + * Return an opaque handle to this window that uniquely identifies it within this driver instance. + * This can be used to switch to this window at a later date * - * @return This driver focused on the top window/first frame. + * @return the current window handle */ - WebDriver defaultContent(); + String getWindowHandle(); /** - * Switches to the element that currently has focus within the document currently "switched to", - * or the body element if this cannot be detected. This matches the semantics of calling - * "document.activeElement" in Javascript. + * Send future commands to a different frame or window. * - * @return The WebElement with focus, or the body element if no element with focus can be - * detected. + * @return A TargetLocator which can be used to select a frame or window + * @see org.openqa.selenium.WebDriver.TargetLocator */ - WebElement activeElement(); + TargetLocator switchTo(); /** - * Switches to the currently active modal dialog for this particular driver instance. + * An abstraction allowing the driver to access the browser's history and to navigate to a given + * URL. * - * @return A handle to the dialog. - * @throws NoAlertPresentException If the dialog cannot be found + * @return A {@link org.openqa.selenium.WebDriver.Navigation} that allows the selection of what to + * do next */ - Alert alert(); - } + Navigation navigate(); - interface Navigation { /** - * Move back a single "item" in the browser's history. - */ - void back(); - - /** - * Move a single "item" forward in the browser's history. Does nothing if we are on the latest - * page viewed. - */ - void forward(); - - - /** - * Load a new web page in the current browser window. This is done using an HTTP GET operation, - * and the method will block until the load is complete. This will follow redirects issued - * either by the server or as a meta-redirect from within the returned HTML. Should a - * meta-redirect "rest" for any duration of time, it is best to wait until this timeout is over, - * since should the underlying page change whilst your test is executing the results of future - * calls against this interface will be against the freshly loaded page. + * Gets the Option interface * - * @param url The URL to load. It is best to use a fully qualified URL - */ - void to(String url); + * @return An option interface + * @see org.openqa.selenium.WebDriver.Options + */ + Options manage(); + + /** + * An interface for managing stuff you would do in a browser menu + */ + interface Options { + + /** + * Add a specific cookie. If the cookie's domain name is left blank, it is assumed that the + * cookie is meant for the domain of the current document. + * + * @param cookie The cookie to add. + */ + void addCookie(Cookie cookie); + + /** + * Delete the named cookie from the current domain. This is equivalent to setting the named + * cookie's expiry date to some time in the past. + * + * @param name The name of the cookie to delete + */ + void deleteCookieNamed(String name); + + /** + * Delete a cookie from the browser's "cookie jar". The domain of the cookie will be ignored. + * + * @param cookie nom nom nom + */ + void deleteCookie(Cookie cookie); + + /** + * Delete all the cookies for the current domain. + */ + void deleteAllCookies(); + + /** + * Get all the cookies for the current domain. This is the equivalent of calling + * "document.cookie" and parsing the result + * + * @return A Set of cookies for the current domain. + */ + Set getCookies(); + + /** + * Get a cookie with a given name. + * + * @param name the name of the cookie + * @return the cookie, or null if no cookie with the given name is present + */ + Cookie getCookieNamed(String name); + + /** + * @return the interface for managing driver timeouts. + */ + Timeouts timeouts(); + + /** + * @return the interface for controlling IME engines to generate complex-script input. + */ + ImeHandler ime(); + + /** + * @return the interface for managing the current window. + */ + Window window(); + + /** + * Gets the {@link Logs} interface used to fetch different types of logs. + *

    + *

    To set the logging preferences {@link LoggingPreferences}. + * + * @return A Logs interface. + */ + @Beta + Logs logs(); + } + + /** + * An interface for managing timeout behavior for WebDriver instances. + */ + interface Timeouts { + + /** + * Specifies the amount of time the driver should wait when searching for an element if it is + * not immediately present. + *

    + * When searching for a single element, the driver should poll the page until the element has + * been found, or this timeout expires before throwing a {@link NoSuchElementException}. When + * searching for multiple elements, the driver should poll the page until at least one element + * has been found or this timeout has expired. + *

    + * Increasing the implicit wait timeout should be used judiciously as it will have an adverse + * effect on test run time, especially when used with slower location strategies like XPath. + * + * @param time The amount of time to wait. + * @param unit The unit of measure for {@code time}. + * @return A self reference. + */ + Timeouts implicitlyWait(long time, TimeUnit unit); + + /** + * Sets the amount of time to wait for an asynchronous script to finish execution before + * throwing an error. If the timeout is negative, then the script will be allowed to run + * indefinitely. + * + * @param time The timeout value. + * @param unit The unit of time. + * @return A self reference. + * @see JavascriptExecutor#executeAsyncScript(String, Object...) + */ + Timeouts setScriptTimeout(long time, TimeUnit unit); + + /** + * Sets the amount of time to wait for a page load to complete before throwing an error. + * If the timeout is negative, page loads can be indefinite. + * + * @param time The timeout value. + * @param unit The unit of time. + * @return A Timeouts interface. + */ + Timeouts pageLoadTimeout(long time, TimeUnit unit); + } + + /** + * Used to locate a given frame or window. + */ + interface TargetLocator { + /** + * Select a frame by its (zero-based) index. Selecting a frame by index is equivalent to the + * JS expression window.frames[index] where "window" is the DOM window represented by the + * current context. Once the frame has been selected, all subsequent calls on the WebDriver + * interface are made to that frame. + * + * @param index (zero-based) index + * @return This driver focused on the given frame + * @throws NoSuchFrameException If the frame cannot be found + */ + WebDriver frame(int index); + + /** + * Select a frame by its name or ID. Frames located by matching name attributes are always given + * precedence over those matched by ID. + * + * @param nameOrId the name of the frame window, the id of the <frame> or <iframe> + * element, or the (zero-based) index + * @return This driver focused on the given frame + * @throws NoSuchFrameException If the frame cannot be found + */ + WebDriver frame(String nameOrId); + + /** + * Select a frame using its previously located {@link WebElement}. + * + * @param frameElement The frame element to switch to. + * @return This driver focused on the given frame. + * @throws NoSuchFrameException If the given element is neither an IFRAME nor a FRAME element. + * @throws StaleElementReferenceException If the WebElement has gone stale. + * @see WebDriver#findElement(By) + */ + WebDriver frame(WebElement frameElement); + + /** + * Change focus to the parent context. If the current context is the top level browsing context, + * the context remains unchanged. + * + * @return This driver focused on the parent frame + */ + WebDriver parentFrame(); + + /** + * Switch the focus of future commands for this driver to the window with the given name/handle. + * + * @param nameOrHandle The name of the window or the handle as returned by + * {@link WebDriver#getWindowHandle()} + * @return This driver focused on the given window + * @throws NoSuchWindowException If the window cannot be found + */ + WebDriver window(String nameOrHandle); + + /** + * Selects either the first frame on the page, or the main document when a page contains + * iframes. + * + * @return This driver focused on the top window/first frame. + */ + WebDriver defaultContent(); + + /** + * Switches to the element that currently has focus within the document currently "switched to", + * or the body element if this cannot be detected. This matches the semantics of calling + * "document.activeElement" in Javascript. + * + * @return The WebElement with focus, or the body element if no element with focus can be + * detected. + */ + WebElement activeElement(); + + /** + * Switches to the currently active modal dialog for this particular driver instance. + * + * @return A handle to the dialog. + * @throws NoAlertPresentException If the dialog cannot be found + */ + Alert alert(); + } + + interface Navigation { + /** + * Move back a single "item" in the browser's history. + */ + void back(); + + /** + * Move a single "item" forward in the browser's history. Does nothing if we are on the latest + * page viewed. + */ + void forward(); + + + /** + * Load a new web page in the current browser window. This is done using an HTTP GET operation, + * and the method will block until the load is complete. This will follow redirects issued + * either by the server or as a meta-redirect from within the returned HTML. Should a + * meta-redirect "rest" for any duration of time, it is best to wait until this timeout is over, + * since should the underlying page change whilst your test is executing the results of future + * calls against this interface will be against the freshly loaded page. + * + * @param url The URL to load. It is best to use a fully qualified URL + */ + void to(String url); + + /** + * Overloaded version of {@link #to(String)} that makes it easy to pass in a URL. + * + * @param url URL + */ + void to(URL url); + + /** + * Refresh the current page + */ + void refresh(); + } + + /** + * An interface for managing input methods. + */ + interface ImeHandler { + /** + * All available engines on the machine. To use an engine, it has to be activated. + * + * @return list of available IME engines. + * @throws ImeNotAvailableException if the host does not support IME. + */ + List getAvailableEngines(); + + /** + * Get the name of the active IME engine. The name string is platform-specific. + * + * @return name of the active IME engine. + * @throws ImeNotAvailableException if the host does not support IME. + */ + String getActiveEngine(); + + /** + * Indicates whether IME input active at the moment (not if it's available). + * + * @return true if IME input is available and currently active, false otherwise. + * @throws ImeNotAvailableException if the host does not support IME. + */ + boolean isActivated(); + + /** + * De-activate IME input (turns off the currently activated engine). Note that getActiveEngine + * may still return the name of the engine but isActivated will return false. + * + * @throws ImeNotAvailableException if the host does not support IME. + */ + void deactivate(); + + /** + * Make an engines that is available (appears on the list returned by getAvailableEngines) + * active. After this call, the only loaded engine on the IME daemon will be this one and the + * input sent using sendKeys will be converted by the engine. Noteh that this is a + * platform-independent method of activating IME (the platform-specific way being using keyboard + * shortcuts). + * + * @param engine name of engine to activate. + * @throws ImeNotAvailableException if the host does not support IME. + * @throws ImeActivationFailedException if the engine is not available or if activation failed + * for other reasons. + */ + void activateEngine(String engine); + } - /** - * Overloaded version of {@link #to(String)} that makes it easy to pass in a URL. - * - * @param url URL - */ - void to(URL url); - - /** - * Refresh the current page - */ - void refresh(); - } - - /** - * An interface for managing input methods. - */ - interface ImeHandler { - /** - * All available engines on the machine. To use an engine, it has to be activated. - * - * @return list of available IME engines. - * @throws ImeNotAvailableException if the host does not support IME. - */ - List getAvailableEngines(); - - /** - * Get the name of the active IME engine. The name string is platform-specific. - * - * @return name of the active IME engine. - * @throws ImeNotAvailableException if the host does not support IME. - */ - String getActiveEngine(); - - /** - * Indicates whether IME input active at the moment (not if it's available). - * - * @return true if IME input is available and currently active, false otherwise. - * @throws ImeNotAvailableException if the host does not support IME. - */ - boolean isActivated(); - - /** - * De-activate IME input (turns off the currently activated engine). Note that getActiveEngine - * may still return the name of the engine but isActivated will return false. - * - * @throws ImeNotAvailableException if the host does not support IME. - */ - void deactivate(); - - /** - * Make an engines that is available (appears on the list returned by getAvailableEngines) - * active. After this call, the only loaded engine on the IME daemon will be this one and the - * input sent using sendKeys will be converted by the engine. Noteh that this is a - * platform-independent method of activating IME (the platform-specific way being using keyboard - * shortcuts). - * - * - * @param engine name of engine to activate. - * @throws ImeNotAvailableException if the host does not support IME. - * @throws ImeActivationFailedException if the engine is not available or if activation failed - * for other reasons. - */ - void activateEngine(String engine); - } - - @Beta - interface Window { - /** - * Set the size of the current window. This will change the outer window dimension, - * not just the view port, synonymous to window.resizeTo() in JS. - * - * @param targetSize The target size. - */ - void setSize(Dimension targetSize); - - /** - * Set the position of the current window. This is relative to the upper left corner of the - * screen, synonymous to window.moveTo() in JS. - * - * @param targetPosition The target position of the window. - */ - void setPosition(Point targetPosition); - - /** - * Get the size of the current window. This will return the outer window dimension, not just - * the view port. - * - * @return The current window size. - */ - Dimension getSize(); - - /** - * Get the position of the current window, relative to the upper left corner of the screen. - * - * @return The current window position. - */ - Point getPosition(); - - /** - * Maximizes the current window if it is not already maximized - */ - void maximize(); - - /** - * Fullscreen the current window if it is not already fullscreen - */ - void fullscreen(); - } + @Beta + interface Window { + /** + * Set the size of the current window. This will change the outer window dimension, + * not just the view port, synonymous to window.resizeTo() in JS. + * + * @param targetSize The target size. + */ + void setSize(Dimension targetSize); + + /** + * Set the position of the current window. This is relative to the upper left corner of the + * screen, synonymous to window.moveTo() in JS. + * + * @param targetPosition The target position of the window. + */ + void setPosition(Point targetPosition); + + /** + * Get the size of the current window. This will return the outer window dimension, not just + * the view port. + * + * @return The current window size. + */ + Dimension getSize(); + + /** + * Get the position of the current window, relative to the upper left corner of the screen. + * + * @return The current window position. + */ + Point getPosition(); + + /** + * Maximizes the current window if it is not already maximized + */ + void maximize(); + + /** + * Fullscreen the current window if it is not already fullscreen + */ + void fullscreen(); + } } diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 4887d7fe6..6e4492a1b 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -29,191 +29,191 @@ * future calls to this instance will fail. */ public interface WebElement extends SearchContext, TakesScreenshot { - /** - * Click this element. If this causes a new page to load, you - * should discard all references to this element and any further - * operations performed on this element will throw a - * StaleElementReferenceException. - * - * Note that if click() is done by sending a native event (which is - * the default on most browsers/platforms) then the method will - * _not_ wait for the next page to load and the caller should verify - * that themselves. - - * - * There are some preconditions for an element to be clicked. The - * element must be visible and it must have a height and width - * greater then 0. - * - * @throws StaleElementReferenceException If the element no - * longer exists as initially defined - */ - void click(); - - /** - * If this current element is a form, or an element within a form, then this will be submitted to - * the remote server. If this causes the current page to change, then this method will block until - * the new page is loaded. - * - * @throws NoSuchElementException If the given element is not within a form - */ - void submit(); - - /** - * Use this method to simulate typing into an element, which may set its value. - * - * @param keysToSend character sequence to send to the element - */ - void sendKeys(CharSequence... keysToSend); - - /** - * If this element is a text entry element, this will clear the value. Has no effect on other - * elements. Text entry elements are INPUT and TEXTAREA elements. - * - * Note that the events fired by this event may not be as you'd expect. In particular, we don't - * fire any keyboard or mouse events. If you want to ensure keyboard events are fired, consider - * using something like {@link #sendKeys(CharSequence...)} with the backspace key. To ensure - * you get a change event, consider following with a call to {@link #sendKeys(CharSequence...)} - * with the tab key. - */ - void clear(); - - /** - * Get the tag name of this element. Not the value of the name attribute: will return - * "input" for the element <input name="foo" />. - * - * @return The tag name of this element. - */ - String getTagName(); - - /** - * Get the value of a the given attribute of the element. Will return the current value, even if - * this has been modified after the page has been loaded. More exactly, this method will return - * the value of the given attribute, unless that attribute is not present, in which case the value - * of the property with the same name is returned (for example for the "value" property of a - * textarea element). If neither value is set, null is returned. The "style" attribute is - * converted as best can be to a text representation with a trailing semi-colon. The following are - * deemed to be "boolean" attributes, and will return either "true" or null: - * - * async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked, - * defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, - * iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, - * novalidate, nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, - * seeking, selected, spellcheck, truespeed, willvalidate - * - * Finally, the following commonly mis-capitalized attribute/property names are evaluated as - * expected: - * - *

      - *
    • "class" - *
    • "readonly" - *
    - * - * @param name The name of the attribute. - * @return The attribute/property's current value or null if the value is not set. - */ - String getAttribute(String name); - - /** - * Determine whether or not this element is selected or not. This operation only applies to input - * elements such as checkboxes, options in a select and radio buttons. - * - * @return True if the element is currently selected or checked, false otherwise. - */ - boolean isSelected(); - - /** - * Is the element currently enabled or not? This will generally return true for everything but - * disabled input elements. - * - * @return True if the element is enabled, false otherwise. - */ - boolean isEnabled(); - - /** - * Get the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, - * without any leading or trailing whitespace. - * - * @return The innerText of this element. - */ - String getText(); - - /** - * Find all elements within the current context using the given mechanism. When using xpath be - * aware that webdriver follows standard conventions: a search prefixed with "//" will search the - * entire document, not just the children of this current node. Use ".//" to limit your search to - * the children of this WebElement. - * This method is affected by the 'implicit wait' times in force at the time of execution. When - * implicitly waiting, this method will return as soon as there are more than 0 items in the - * found collection, or will return an empty list if the timeout is reached. - * - * @param by The locating mechanism to use - * @return A list of all {@link WebElement}s, or an empty list if nothing matches. - * @see org.openqa.selenium.By - * @see org.openqa.selenium.WebDriver.Timeouts - */ - List findElements(By by); - - /** - * Find the first {@link WebElement} using the given method. See the note in - * {@link #findElements(By)} about finding via XPath. - * This method is affected by the 'implicit wait' times in force at the time of execution. - * The findElement(..) invocation will return a matching row, or try again repeatedly until - * the configured timeout is reached. - * - * findElement should not be used to look for non-present elements, use {@link #findElements(By)} - * and assert zero length response instead. - * - * @param by The locating mechanism - * @return The first matching element on the current context. - * @throws NoSuchElementException If no matching elements are found - * @see org.openqa.selenium.By - * @see org.openqa.selenium.WebDriver.Timeouts - */ - WebElement findElement(By by); - - /** - * Is this element displayed or not? This method avoids the problem of having to parse an - * element's "style" attribute. - * - * @return Whether or not the element is displayed - */ - boolean isDisplayed(); - - /** - * Where on the page is the top left-hand corner of the rendered element? - * - * @return A point, containing the location of the top left-hand corner of the element - */ - Point getLocation(); - - /** - * What is the width and height of the rendered element? - * - * @return The size of the element on the page. - */ - Dimension getSize(); - - /** - * @return The location and size of the rendered element - */ - Rectangle getRect(); - - /** - * Get the value of a given CSS property. - * Color values should be returned as rgba strings, so, - * for example if the "background-color" property is set as "green" in the - * HTML source, the returned value will be "rgba(0, 255, 0, 1)". - * - * Note that shorthand CSS properties (e.g. background, font, border, border-top, margin, - * margin-top, padding, padding-top, list-style, outline, pause, cue) are not returned, - * in accordance with the - * DOM CSS2 specification - * - you should directly access the longhand properties (e.g. background-color) to access the - * desired values. - * - * @param propertyName the css property name of the element - * @return The current, computed value of the property. - */ - String getCssValue(String propertyName); + /** + * Click this element. If this causes a new page to load, you + * should discard all references to this element and any further + * operations performed on this element will throw a + * StaleElementReferenceException. + *

    + * Note that if click() is done by sending a native event (which is + * the default on most browsers/platforms) then the method will + * _not_ wait for the next page to load and the caller should verify + * that themselves. + *

    + *

    + * There are some preconditions for an element to be clicked. The + * element must be visible and it must have a height and width + * greater then 0. + * + * @throws StaleElementReferenceException If the element no + * longer exists as initially defined + */ + void click(); + + /** + * If this current element is a form, or an element within a form, then this will be submitted to + * the remote server. If this causes the current page to change, then this method will block until + * the new page is loaded. + * + * @throws NoSuchElementException If the given element is not within a form + */ + void submit(); + + /** + * Use this method to simulate typing into an element, which may set its value. + * + * @param keysToSend character sequence to send to the element + */ + void sendKeys(CharSequence... keysToSend); + + /** + * If this element is a text entry element, this will clear the value. Has no effect on other + * elements. Text entry elements are INPUT and TEXTAREA elements. + *

    + * Note that the events fired by this event may not be as you'd expect. In particular, we don't + * fire any keyboard or mouse events. If you want to ensure keyboard events are fired, consider + * using something like {@link #sendKeys(CharSequence...)} with the backspace key. To ensure + * you get a change event, consider following with a call to {@link #sendKeys(CharSequence...)} + * with the tab key. + */ + void clear(); + + /** + * Get the tag name of this element. Not the value of the name attribute: will return + * "input" for the element <input name="foo" />. + * + * @return The tag name of this element. + */ + String getTagName(); + + /** + * Get the value of a the given attribute of the element. Will return the current value, even if + * this has been modified after the page has been loaded. More exactly, this method will return + * the value of the given attribute, unless that attribute is not present, in which case the value + * of the property with the same name is returned (for example for the "value" property of a + * textarea element). If neither value is set, null is returned. The "style" attribute is + * converted as best can be to a text representation with a trailing semi-colon. The following are + * deemed to be "boolean" attributes, and will return either "true" or null: + *

    + * async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked, + * defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, + * iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, + * novalidate, nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, + * seeking, selected, spellcheck, truespeed, willvalidate + *

    + * Finally, the following commonly mis-capitalized attribute/property names are evaluated as + * expected: + *

    + *

      + *
    • "class" + *
    • "readonly" + *
    + * + * @param name The name of the attribute. + * @return The attribute/property's current value or null if the value is not set. + */ + String getAttribute(String name); + + /** + * Determine whether or not this element is selected or not. This operation only applies to input + * elements such as checkboxes, options in a select and radio buttons. + * + * @return True if the element is currently selected or checked, false otherwise. + */ + boolean isSelected(); + + /** + * Is the element currently enabled or not? This will generally return true for everything but + * disabled input elements. + * + * @return True if the element is enabled, false otherwise. + */ + boolean isEnabled(); + + /** + * Get the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, + * without any leading or trailing whitespace. + * + * @return The innerText of this element. + */ + String getText(); + + /** + * Find all elements within the current context using the given mechanism. When using xpath be + * aware that webdriver follows standard conventions: a search prefixed with "//" will search the + * entire document, not just the children of this current node. Use ".//" to limit your search to + * the children of this WebElement. + * This method is affected by the 'implicit wait' times in force at the time of execution. When + * implicitly waiting, this method will return as soon as there are more than 0 items in the + * found collection, or will return an empty list if the timeout is reached. + * + * @param by The locating mechanism to use + * @return A list of all {@link WebElement}s, or an empty list if nothing matches. + * @see org.openqa.selenium.By + * @see org.openqa.selenium.WebDriver.Timeouts + */ + List findElements(By by); + + /** + * Find the first {@link WebElement} using the given method. See the note in + * {@link #findElements(By)} about finding via XPath. + * This method is affected by the 'implicit wait' times in force at the time of execution. + * The findElement(..) invocation will return a matching row, or try again repeatedly until + * the configured timeout is reached. + *

    + * findElement should not be used to look for non-present elements, use {@link #findElements(By)} + * and assert zero length response instead. + * + * @param by The locating mechanism + * @return The first matching element on the current context. + * @throws NoSuchElementException If no matching elements are found + * @see org.openqa.selenium.By + * @see org.openqa.selenium.WebDriver.Timeouts + */ + WebElement findElement(By by); + + /** + * Is this element displayed or not? This method avoids the problem of having to parse an + * element's "style" attribute. + * + * @return Whether or not the element is displayed + */ + boolean isDisplayed(); + + /** + * Where on the page is the top left-hand corner of the rendered element? + * + * @return A point, containing the location of the top left-hand corner of the element + */ + Point getLocation(); + + /** + * What is the width and height of the rendered element? + * + * @return The size of the element on the page. + */ + Dimension getSize(); + + /** + * @return The location and size of the rendered element + */ + Rectangle getRect(); + + /** + * Get the value of a given CSS property. + * Color values should be returned as rgba strings, so, + * for example if the "background-color" property is set as "green" in the + * HTML source, the returned value will be "rgba(0, 255, 0, 1)". + *

    + * Note that shorthand CSS properties (e.g. background, font, border, border-top, margin, + * margin-top, padding, padding-top, list-style, outline, pause, cue) are not returned, + * in accordance with the + * DOM CSS2 specification + * - you should directly access the longhand properties (e.g. background-color) to access the + * desired values. + * + * @param propertyName the css property name of the element + * @return The current, computed value of the property. + */ + String getCssValue(String propertyName); } diff --git a/src/main/java/org/openqa/selenium/internal/FindsByClassName.java b/src/main/java/org/openqa/selenium/internal/FindsByClassName.java index c7f742f0d..38e747a1a 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByClassName.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByClassName.java @@ -22,7 +22,7 @@ import java.util.List; public interface FindsByClassName { - WebElement findElementByClassName(String using); + WebElement findElementByClassName(String using); - List findElementsByClassName(String using); + List findElementsByClassName(String using); } diff --git a/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java b/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java index 5f221c61d..f897a4dab 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java @@ -22,7 +22,7 @@ import java.util.List; public interface FindsByCssSelector { - WebElement findElementByCssSelector(String using); + WebElement findElementByCssSelector(String using); - List findElementsByCssSelector(String using); + List findElementsByCssSelector(String using); } diff --git a/src/main/java/org/openqa/selenium/internal/FindsById.java b/src/main/java/org/openqa/selenium/internal/FindsById.java index a62e07999..4b2dcc32c 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsById.java +++ b/src/main/java/org/openqa/selenium/internal/FindsById.java @@ -22,7 +22,7 @@ import java.util.List; public interface FindsById { - WebElement findElementById(String using); + WebElement findElementById(String using); - List findElementsById(String using); + List findElementsById(String using); } diff --git a/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java b/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java index f79ecb46f..bfad6f16e 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java @@ -22,11 +22,11 @@ import java.util.List; public interface FindsByLinkText { - WebElement findElementByLinkText(String using); + WebElement findElementByLinkText(String using); - List findElementsByLinkText(String using); + List findElementsByLinkText(String using); - WebElement findElementByPartialLinkText(String using); + WebElement findElementByPartialLinkText(String using); - List findElementsByPartialLinkText(String using); + List findElementsByPartialLinkText(String using); } diff --git a/src/main/java/org/openqa/selenium/internal/FindsByName.java b/src/main/java/org/openqa/selenium/internal/FindsByName.java index f4c3f559a..7eee3cb2e 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByName.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByName.java @@ -22,7 +22,7 @@ import java.util.List; public interface FindsByName { - WebElement findElementByName(String using); + WebElement findElementByName(String using); - List findElementsByName(String using); + List findElementsByName(String using); } diff --git a/src/main/java/org/openqa/selenium/internal/FindsByTagName.java b/src/main/java/org/openqa/selenium/internal/FindsByTagName.java index 5c21fe352..4055b35da 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByTagName.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByTagName.java @@ -22,7 +22,7 @@ import java.util.List; public interface FindsByTagName { - WebElement findElementByTagName(String using); + WebElement findElementByTagName(String using); - List findElementsByTagName(String using); + List findElementsByTagName(String using); } diff --git a/src/main/java/org/openqa/selenium/internal/FindsByXPath.java b/src/main/java/org/openqa/selenium/internal/FindsByXPath.java index 49c0d72be..3823e47fe 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByXPath.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByXPath.java @@ -22,7 +22,7 @@ import java.util.List; public interface FindsByXPath { - WebElement findElementByXPath(String using); + WebElement findElementByXPath(String using); - List findElementsByXPath(String using); + List findElementsByXPath(String using); } From d28c76d90643aa10ca70611a98434f8f5cccfc17 Mon Sep 17 00:00:00 2001 From: Sergey Tikhomirov Date: Mon, 6 Jun 2016 23:45:22 +0300 Subject: [PATCH 111/114] Generic searching interfaces Changes from the https://github.com/SeleniumHQ/selenium/pull/863 --- src/main/java/org/openqa/selenium/SearchContext.java | 4 ++-- src/main/java/org/openqa/selenium/WebDriver.java | 4 ++-- src/main/java/org/openqa/selenium/WebElement.java | 4 ++-- .../org/openqa/selenium/internal/FindsByClassName.java | 4 ++-- .../org/openqa/selenium/internal/FindsByCssSelector.java | 4 ++-- src/main/java/org/openqa/selenium/internal/FindsById.java | 4 ++-- .../org/openqa/selenium/internal/FindsByLinkText.java | 8 ++++---- .../java/org/openqa/selenium/internal/FindsByName.java | 4 ++-- .../java/org/openqa/selenium/internal/FindsByTagName.java | 4 ++-- .../java/org/openqa/selenium/internal/FindsByXPath.java | 4 ++-- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/openqa/selenium/SearchContext.java b/src/main/java/org/openqa/selenium/SearchContext.java index b8b484e36..79501d6d8 100644 --- a/src/main/java/org/openqa/selenium/SearchContext.java +++ b/src/main/java/org/openqa/selenium/SearchContext.java @@ -27,7 +27,7 @@ public interface SearchContext { * @return A list of all {@link WebElement}s, or an empty list if nothing matches * @see org.openqa.selenium.By */ - List findElements(By by); + List findElements(By by); /** @@ -37,5 +37,5 @@ public interface SearchContext { * @return The first matching element on the current context * @throws NoSuchElementException If no matching elements are found */ - WebElement findElement(By by); + T findElement(By by); } diff --git a/src/main/java/org/openqa/selenium/WebDriver.java b/src/main/java/org/openqa/selenium/WebDriver.java index e73d2df49..dde47d84b 100644 --- a/src/main/java/org/openqa/selenium/WebDriver.java +++ b/src/main/java/org/openqa/selenium/WebDriver.java @@ -90,7 +90,7 @@ public interface WebDriver extends SearchContext { * @see org.openqa.selenium.By * @see org.openqa.selenium.WebDriver.Timeouts */ - List findElements(By by); + List findElements(By by); /** @@ -108,7 +108,7 @@ public interface WebDriver extends SearchContext { * @see org.openqa.selenium.By * @see org.openqa.selenium.WebDriver.Timeouts */ - WebElement findElement(By by); + T findElement(By by); // Misc diff --git a/src/main/java/org/openqa/selenium/WebElement.java b/src/main/java/org/openqa/selenium/WebElement.java index 6e4492a1b..76aae6a3b 100644 --- a/src/main/java/org/openqa/selenium/WebElement.java +++ b/src/main/java/org/openqa/selenium/WebElement.java @@ -152,7 +152,7 @@ public interface WebElement extends SearchContext, TakesScreenshot { * @see org.openqa.selenium.By * @see org.openqa.selenium.WebDriver.Timeouts */ - List findElements(By by); + List findElements(By by); /** * Find the first {@link WebElement} using the given method. See the note in @@ -170,7 +170,7 @@ public interface WebElement extends SearchContext, TakesScreenshot { * @see org.openqa.selenium.By * @see org.openqa.selenium.WebDriver.Timeouts */ - WebElement findElement(By by); + T findElement(By by); /** * Is this element displayed or not? This method avoids the problem of having to parse an diff --git a/src/main/java/org/openqa/selenium/internal/FindsByClassName.java b/src/main/java/org/openqa/selenium/internal/FindsByClassName.java index 38e747a1a..cc28072ec 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByClassName.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByClassName.java @@ -22,7 +22,7 @@ import java.util.List; public interface FindsByClassName { - WebElement findElementByClassName(String using); + T findElementByClassName(String using); - List findElementsByClassName(String using); + List findElementsByClassName(String using); } diff --git a/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java b/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java index f897a4dab..74074e534 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByCssSelector.java @@ -22,7 +22,7 @@ import java.util.List; public interface FindsByCssSelector { - WebElement findElementByCssSelector(String using); + T findElementByCssSelector(String using); - List findElementsByCssSelector(String using); + List findElementsByCssSelector(String using); } diff --git a/src/main/java/org/openqa/selenium/internal/FindsById.java b/src/main/java/org/openqa/selenium/internal/FindsById.java index 4b2dcc32c..ee4fdd9d3 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsById.java +++ b/src/main/java/org/openqa/selenium/internal/FindsById.java @@ -22,7 +22,7 @@ import java.util.List; public interface FindsById { - WebElement findElementById(String using); + T findElementById(String using); - List findElementsById(String using); + List findElementsById(String using); } diff --git a/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java b/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java index bfad6f16e..52c09f6a1 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByLinkText.java @@ -22,11 +22,11 @@ import java.util.List; public interface FindsByLinkText { - WebElement findElementByLinkText(String using); + T findElementByLinkText(String using); - List findElementsByLinkText(String using); + List findElementsByLinkText(String using); - WebElement findElementByPartialLinkText(String using); + T findElementByPartialLinkText(String using); - List findElementsByPartialLinkText(String using); + List findElementsByPartialLinkText(String using); } diff --git a/src/main/java/org/openqa/selenium/internal/FindsByName.java b/src/main/java/org/openqa/selenium/internal/FindsByName.java index 7eee3cb2e..7d39ac1d8 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByName.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByName.java @@ -22,7 +22,7 @@ import java.util.List; public interface FindsByName { - WebElement findElementByName(String using); + T findElementByName(String using); - List findElementsByName(String using); + List findElementsByName(String using); } diff --git a/src/main/java/org/openqa/selenium/internal/FindsByTagName.java b/src/main/java/org/openqa/selenium/internal/FindsByTagName.java index 4055b35da..f5df666af 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByTagName.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByTagName.java @@ -22,7 +22,7 @@ import java.util.List; public interface FindsByTagName { - WebElement findElementByTagName(String using); + T findElementByTagName(String using); - List findElementsByTagName(String using); + List findElementsByTagName(String using); } diff --git a/src/main/java/org/openqa/selenium/internal/FindsByXPath.java b/src/main/java/org/openqa/selenium/internal/FindsByXPath.java index 3823e47fe..bea6007cb 100644 --- a/src/main/java/org/openqa/selenium/internal/FindsByXPath.java +++ b/src/main/java/org/openqa/selenium/internal/FindsByXPath.java @@ -22,7 +22,7 @@ import java.util.List; public interface FindsByXPath { - WebElement findElementByXPath(String using); + T findElementByXPath(String using); - List findElementsByXPath(String using); + List findElementsByXPath(String using); } From bc79b1ab8014914bc233d198dc952446b952179e Mon Sep 17 00:00:00 2001 From: Sergey Tikhomirov Date: Wed, 8 Jun 2016 00:30:42 +0300 Subject: [PATCH 112/114] API re-design --- .../DefaultGenericMobileDriver.java | 4 +- .../io/appium/java_client/MobileDriver.java | 51 ++++++++++++++++--- .../GenericFindsByClassName.java | 6 +++ .../GenericFindsByCssSelector.java | 6 +++ .../searchcontext/GenericFindsById.java | 6 +++ .../searchcontext/GenericFindsByLinkText.java | 6 +++ .../searchcontext/GenericFindsByName.java | 6 +++ .../searchcontext/GenericFindsByTagName.java | 6 +++ .../searchcontext/GenericFindsByXPath.java | 6 +++ .../searchcontext/GenericSearchContext.java | 6 +++ 10 files changed, 93 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/appium/java_client/DefaultGenericMobileDriver.java b/src/main/java/io/appium/java_client/DefaultGenericMobileDriver.java index de55a4282..eb53c6121 100644 --- a/src/main/java/io/appium/java_client/DefaultGenericMobileDriver.java +++ b/src/main/java/io/appium/java_client/DefaultGenericMobileDriver.java @@ -39,9 +39,7 @@ @SuppressWarnings({"unchecked", "rawtypes"}) abstract class DefaultGenericMobileDriver extends RemoteWebDriver - implements GenericSearchContext, GenericFindsById, GenericFindsByXPath, - GenericFindsByLinkText, GenericFindsByTagName, GenericFindsByClassName, - GenericFindsByCssSelector, GenericFindsByName, MobileDriver { + implements MobileDriver { public DefaultGenericMobileDriver(CommandExecutor executor, Capabilities desiredCapabilities) { super(executor, desiredCapabilities); diff --git a/src/main/java/io/appium/java_client/MobileDriver.java b/src/main/java/io/appium/java_client/MobileDriver.java index 0e13181f8..c759fb6a4 100644 --- a/src/main/java/io/appium/java_client/MobileDriver.java +++ b/src/main/java/io/appium/java_client/MobileDriver.java @@ -16,17 +16,54 @@ package io.appium.java_client; -import org.openqa.selenium.ContextAware; -import org.openqa.selenium.Rotatable; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; +import org.openqa.selenium.*; import org.openqa.selenium.html5.LocationContext; +import org.openqa.selenium.internal.*; import org.openqa.selenium.remote.Response; +import java.util.List; import java.util.Map; -public interface MobileDriver extends WebDriver, PerformsTouchActions, ContextAware, Rotatable, - FindsByAccessibilityId, LocationContext, DeviceActionShortcuts, TouchShortcuts, - InteractsWithFiles, InteractsWithApps, HasAppStrings { +public interface MobileDriver extends WebDriver, PerformsTouchActions, ContextAware, Rotatable, + FindsByAccessibilityId, LocationContext, DeviceActionShortcuts, TouchShortcuts, + InteractsWithFiles, InteractsWithApps, HasAppStrings, FindsByClassName, FindsByCssSelector, FindsById, + FindsByLinkText, FindsByName, FindsByTagName, FindsByXPath { + Response execute(String driverCommand, Map parameters); + + List findElements(By by); + + T findElement(By by); + + T findElementByClassName(String className); + + List findElementsByClassName(String className); + + T findElementByCssSelector(String cssSelector); + + List findElementsByCssSelector(String cssSelector); + + T findElementById(String id); + + List findElementsById(String id); + + T findElementByLinkText(String linkText); + + List findElementsByLinkText(String linkText); + + T findElementByPartialLinkText(String partialLinkText); + + List findElementsByPartialLinkText(String partialLinkText); + + T findElementByName(String name); + + List findElementsByName(String name); + + T findElementByTagName(String tagName); + + List findElementsByTagName(String tagName); + + T findElementByXPath(String xPath); + + List findElementsByXPath(String xPath); } diff --git a/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByClassName.java b/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByClassName.java index c7a4485f3..e9dc6c202 100644 --- a/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByClassName.java +++ b/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByClassName.java @@ -20,6 +20,12 @@ import java.util.List; +@Deprecated +/** + * This interface became deprecated. Use + * {@link org.openqa.selenium.internal.FindsByClassName} + * instead. + */ public interface GenericFindsByClassName { T findElementByClassName(String className); diff --git a/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByCssSelector.java b/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByCssSelector.java index 5dcfa093b..200c20bd6 100644 --- a/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByCssSelector.java +++ b/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByCssSelector.java @@ -20,6 +20,12 @@ import java.util.List; +@Deprecated +/** + * This interface became deprecated. Use + * {@link org.openqa.selenium.internal.FindsByCssSelector} + * instead. + */ public interface GenericFindsByCssSelector { T findElementByCssSelector(String cssSelector); diff --git a/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsById.java b/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsById.java index 98ce156b8..5e6c7c870 100644 --- a/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsById.java +++ b/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsById.java @@ -20,6 +20,12 @@ import java.util.List; +@Deprecated +/** + * This interface became deprecated. Use + * {@link org.openqa.selenium.internal.FindsById} + * instead. + */ public interface GenericFindsById { T findElementById(String id); diff --git a/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByLinkText.java b/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByLinkText.java index b48585d43..353c44af5 100644 --- a/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByLinkText.java +++ b/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByLinkText.java @@ -20,6 +20,12 @@ import java.util.List; +@Deprecated +/** + * This interface became deprecated. Use + * {@link org.openqa.selenium.internal.FindsByLinkText} + * instead. + */ public interface GenericFindsByLinkText { T findElementByLinkText(String linkText); diff --git a/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByName.java b/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByName.java index ec1431009..5ea24a8ca 100644 --- a/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByName.java +++ b/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByName.java @@ -20,6 +20,12 @@ import java.util.List; +@Deprecated +/** + * This interface became deprecated. Use + * {@link org.openqa.selenium.internal.FindsByName} + * instead. + */ public interface GenericFindsByName { T findElementByName(String name); diff --git a/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByTagName.java b/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByTagName.java index 98a22c333..54be50396 100644 --- a/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByTagName.java +++ b/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByTagName.java @@ -20,6 +20,12 @@ import java.util.List; +@Deprecated +/** + * This interface became deprecated. Use + * {@link org.openqa.selenium.internal.FindsByTagName} + * instead. + */ public interface GenericFindsByTagName { T findElementByTagName(String tagName); diff --git a/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByXPath.java b/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByXPath.java index 1ba9f9897..105f68344 100644 --- a/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByXPath.java +++ b/src/main/java/io/appium/java_client/generic/searchcontext/GenericFindsByXPath.java @@ -20,6 +20,12 @@ import java.util.List; +@Deprecated +/** + * This interface became deprecated. Use + * {@link org.openqa.selenium.internal.FindsByXPath} + * instead. + */ public interface GenericFindsByXPath { T findElementByXPath(String xPath); diff --git a/src/main/java/io/appium/java_client/generic/searchcontext/GenericSearchContext.java b/src/main/java/io/appium/java_client/generic/searchcontext/GenericSearchContext.java index a7609df9e..db902062b 100644 --- a/src/main/java/io/appium/java_client/generic/searchcontext/GenericSearchContext.java +++ b/src/main/java/io/appium/java_client/generic/searchcontext/GenericSearchContext.java @@ -21,6 +21,12 @@ import java.util.List; +@Deprecated +/** + * This interface became deprecated. Use + * {@link org.openqa.selenium.SearchContext} + * instead. + */ public interface GenericSearchContext { List findElements(By by); From 54361c055f11f9cd17e467eb6bec10ada73d1bef Mon Sep 17 00:00:00 2001 From: Sergey Tikhomirov Date: Wed, 8 Jun 2016 00:33:50 +0300 Subject: [PATCH 113/114] Redesign of default generic classes --- .../java_client/DefaultGenericMobileDriver.java | 9 --------- .../java_client/DefaultGenericMobileElement.java | 16 +++------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/main/java/io/appium/java_client/DefaultGenericMobileDriver.java b/src/main/java/io/appium/java_client/DefaultGenericMobileDriver.java index eb53c6121..19555f105 100644 --- a/src/main/java/io/appium/java_client/DefaultGenericMobileDriver.java +++ b/src/main/java/io/appium/java_client/DefaultGenericMobileDriver.java @@ -16,15 +16,6 @@ package io.appium.java_client; -import io.appium.java_client.generic.searchcontext.GenericFindsByClassName; -import io.appium.java_client.generic.searchcontext.GenericFindsByCssSelector; -import io.appium.java_client.generic.searchcontext.GenericFindsById; -import io.appium.java_client.generic.searchcontext.GenericFindsByLinkText; -import io.appium.java_client.generic.searchcontext.GenericFindsByName; -import io.appium.java_client.generic.searchcontext.GenericFindsByTagName; -import io.appium.java_client.generic.searchcontext.GenericFindsByXPath; -import io.appium.java_client.generic.searchcontext.GenericSearchContext; - import org.openqa.selenium.By; import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; diff --git a/src/main/java/io/appium/java_client/DefaultGenericMobileElement.java b/src/main/java/io/appium/java_client/DefaultGenericMobileElement.java index 7aa74bc14..f45e70aa9 100644 --- a/src/main/java/io/appium/java_client/DefaultGenericMobileElement.java +++ b/src/main/java/io/appium/java_client/DefaultGenericMobileElement.java @@ -16,19 +16,10 @@ package io.appium.java_client; -import io.appium.java_client.generic.searchcontext.GenericFindsByClassName; -import io.appium.java_client.generic.searchcontext.GenericFindsByCssSelector; -import io.appium.java_client.generic.searchcontext.GenericFindsById; -import io.appium.java_client.generic.searchcontext.GenericFindsByLinkText; -import io.appium.java_client.generic.searchcontext.GenericFindsByName; -import io.appium.java_client.generic.searchcontext.GenericFindsByTagName; -import io.appium.java_client.generic.searchcontext.GenericFindsByXPath; -import io.appium.java_client.generic.searchcontext.GenericSearchContext; - - import org.openqa.selenium.By; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.WebElement; +import org.openqa.selenium.internal.*; import org.openqa.selenium.remote.RemoteWebElement; import org.openqa.selenium.remote.Response; @@ -37,9 +28,8 @@ @SuppressWarnings({"unchecked", "rawtypes"}) abstract class DefaultGenericMobileElement extends RemoteWebElement - implements GenericSearchContext, GenericFindsById, GenericFindsByXPath, - GenericFindsByLinkText, GenericFindsByTagName, GenericFindsByClassName, - GenericFindsByCssSelector, GenericFindsByName, FindsByAccessibilityId, + implements FindsByClassName, FindsByCssSelector, FindsById, + FindsByLinkText, FindsByName, FindsByTagName, FindsByXPath, FindsByAccessibilityId, TouchableElement { @Override public Response execute(String driverCommand, Map parameters) { From d8729baeea05a017ee56d5b7557cf7d7002e3927 Mon Sep 17 00:00:00 2001 From: Sergey Tikhomirov Date: Wed, 8 Jun 2016 23:41:35 +0300 Subject: [PATCH 114/114] the final improvement and commit --- .../io/appium/java_client/AppiumDriver.java | 2 +- .../DefaultGenericMobileElement.java | 13 +++-- .../io/appium/java_client/MobileDriver.java | 14 +++++- .../io/appium/java_client/MobileElement.java | 13 ++--- .../appium/java_client/TouchableElement.java | 50 ++++++++++++++++++- .../java_client/android/AndroidElement.java | 11 +--- .../io/appium/java_client/ios/IOSElement.java | 12 +---- 7 files changed, 80 insertions(+), 35 deletions(-) diff --git a/src/main/java/io/appium/java_client/AppiumDriver.java b/src/main/java/io/appium/java_client/AppiumDriver.java index 784bad5c6..2f3f626fb 100644 --- a/src/main/java/io/appium/java_client/AppiumDriver.java +++ b/src/main/java/io/appium/java_client/AppiumDriver.java @@ -261,7 +261,7 @@ public List findElementsByXPath(String using) { } @Override public List findElementsByAccessibilityId(String using) { - return (List) findElements("accessibility id", using); + return super.findElementsByAccessibilityId(using); } @Override protected Response execute(String command) { diff --git a/src/main/java/io/appium/java_client/DefaultGenericMobileElement.java b/src/main/java/io/appium/java_client/DefaultGenericMobileElement.java index f45e70aa9..88884e405 100644 --- a/src/main/java/io/appium/java_client/DefaultGenericMobileElement.java +++ b/src/main/java/io/appium/java_client/DefaultGenericMobileElement.java @@ -19,7 +19,6 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.WebElement; -import org.openqa.selenium.internal.*; import org.openqa.selenium.remote.RemoteWebElement; import org.openqa.selenium.remote.Response; @@ -28,9 +27,7 @@ @SuppressWarnings({"unchecked", "rawtypes"}) abstract class DefaultGenericMobileElement extends RemoteWebElement - implements FindsByClassName, FindsByCssSelector, FindsById, - FindsByLinkText, FindsByName, FindsByTagName, FindsByXPath, FindsByAccessibilityId, - TouchableElement { + implements FindsByAccessibilityId, TouchableElement { @Override public Response execute(String driverCommand, Map parameters) { return super.execute(driverCommand, parameters); @@ -40,10 +37,18 @@ abstract class DefaultGenericMobileElement extends RemoteW return super.findElements(by); } + @Override public List findElements(String by, String using) { + return super.findElements(by, using); + } + @Override public T findElement(By by) { return (T) super.findElement(by); } + @Override public T findElement(String by, String using) { + return (T) super.findElement(by, using); + } + @Override public List findElementsById(String id) { return super.findElementsById(id); } diff --git a/src/main/java/io/appium/java_client/MobileDriver.java b/src/main/java/io/appium/java_client/MobileDriver.java index c759fb6a4..e6965aef9 100644 --- a/src/main/java/io/appium/java_client/MobileDriver.java +++ b/src/main/java/io/appium/java_client/MobileDriver.java @@ -16,9 +16,19 @@ package io.appium.java_client; -import org.openqa.selenium.*; +import org.openqa.selenium.By; +import org.openqa.selenium.ContextAware; +import org.openqa.selenium.Rotatable; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; import org.openqa.selenium.html5.LocationContext; -import org.openqa.selenium.internal.*; +import org.openqa.selenium.internal.FindsByClassName; +import org.openqa.selenium.internal.FindsByCssSelector; +import org.openqa.selenium.internal.FindsById; +import org.openqa.selenium.internal.FindsByLinkText; +import org.openqa.selenium.internal.FindsByName; +import org.openqa.selenium.internal.FindsByTagName; +import org.openqa.selenium.internal.FindsByXPath; import org.openqa.selenium.remote.Response; import java.util.List; diff --git a/src/main/java/io/appium/java_client/MobileElement.java b/src/main/java/io/appium/java_client/MobileElement.java index 9b6020d98..ecb878bb1 100644 --- a/src/main/java/io/appium/java_client/MobileElement.java +++ b/src/main/java/io/appium/java_client/MobileElement.java @@ -19,10 +19,8 @@ import org.openqa.selenium.By; import org.openqa.selenium.Dimension; import org.openqa.selenium.Point; -import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.FileDetector; -import java.util.ArrayList; import java.util.List; @SuppressWarnings({"unchecked"}) @@ -69,6 +67,10 @@ public Point getCenter() { return super.findElements(by); } + @Override public List findElements(String by, String using) { + return super.findElements(by, using); + } + @Override public List findElementsById(String id) { return super.findElementsById(id); } @@ -102,11 +104,6 @@ public List findElementsByXPath(String using) { } @Override public List findElementsByAccessibilityId(String using) { - List result = new ArrayList(); - List found = findElements("accessibility id", using); - for (WebElement e : found) { - result.add((MobileElement) e); - } - return result; + return super.findElementsByAccessibilityId(using); } } diff --git a/src/main/java/io/appium/java_client/TouchableElement.java b/src/main/java/io/appium/java_client/TouchableElement.java index e5df6bfc9..757c99626 100644 --- a/src/main/java/io/appium/java_client/TouchableElement.java +++ b/src/main/java/io/appium/java_client/TouchableElement.java @@ -16,13 +16,61 @@ package io.appium.java_client; +import org.openqa.selenium.By; import org.openqa.selenium.WebElement; +import org.openqa.selenium.internal.FindsByClassName; +import org.openqa.selenium.internal.FindsByCssSelector; +import org.openqa.selenium.internal.FindsById; +import org.openqa.selenium.internal.FindsByLinkText; +import org.openqa.selenium.internal.FindsByName; +import org.openqa.selenium.internal.FindsByTagName; +import org.openqa.selenium.internal.FindsByXPath; + +import java.util.List; /** * It supposed that mobile elements could be tappable, swipeable, zoomable and so on. * This interface extends {@link WebElement} and describes this behavior. */ -public interface TouchableElement extends WebElement { +public interface TouchableElement extends WebElement, FindsByClassName, + FindsByCssSelector, FindsById, + FindsByLinkText, FindsByName, FindsByTagName, FindsByXPath { + + List findElements(By by); + + T findElement(By by); + + T findElementByClassName(String className); + + List findElementsByClassName(String className); + + T findElementByCssSelector(String cssSelector); + + List findElementsByCssSelector(String cssSelector); + + T findElementById(String id); + + List findElementsById(String id); + + T findElementByLinkText(String linkText); + + List findElementsByLinkText(String linkText); + + T findElementByPartialLinkText(String partialLinkText); + + List findElementsByPartialLinkText(String partialLinkText); + + T findElementByName(String name); + + List findElementsByName(String name); + + T findElementByTagName(String tagName); + + List findElementsByTagName(String tagName); + + T findElementByXPath(String xPath); + + List findElementsByXPath(String xPath); /** * Convenience method for pinching the given element. diff --git a/src/main/java/io/appium/java_client/android/AndroidElement.java b/src/main/java/io/appium/java_client/android/AndroidElement.java index f21aa7eb8..8bb762993 100644 --- a/src/main/java/io/appium/java_client/android/AndroidElement.java +++ b/src/main/java/io/appium/java_client/android/AndroidElement.java @@ -23,9 +23,7 @@ import io.appium.java_client.MobileElement; import org.openqa.selenium.WebDriverException; -import org.openqa.selenium.WebElement; -import java.util.ArrayList; import java.util.List; @@ -37,7 +35,7 @@ public class AndroidElement extends MobileElement */ @Override public MobileElement findElementByAndroidUIAutomator(String using) throws WebDriverException { - return (MobileElement) findElement("-android uiautomator", using); + return findElement("-android uiautomator", using); } /** @@ -45,12 +43,7 @@ public class AndroidElement extends MobileElement */ @Override public List findElementsByAndroidUIAutomator(String using) throws WebDriverException { - List result = new ArrayList(); - List found = findElements("-android uiautomator", using); - for (WebElement e : found) { - result.add((AndroidElement) e); - } - return result; + return findElements("-android uiautomator", using); } /** diff --git a/src/main/java/io/appium/java_client/ios/IOSElement.java b/src/main/java/io/appium/java_client/ios/IOSElement.java index 23a287b60..2059a854a 100644 --- a/src/main/java/io/appium/java_client/ios/IOSElement.java +++ b/src/main/java/io/appium/java_client/ios/IOSElement.java @@ -21,11 +21,8 @@ import io.appium.java_client.FindsByIosUIAutomation; import io.appium.java_client.MobileCommand; import io.appium.java_client.MobileElement; -import io.appium.java_client.SwipeElementDirection; import org.openqa.selenium.WebDriverException; -import org.openqa.selenium.WebElement; -import java.util.ArrayList; import java.util.List; public class IOSElement extends MobileElement @@ -36,7 +33,7 @@ public class IOSElement extends MobileElement */ @Override public MobileElement findElementByIosUIAutomation(String using) throws WebDriverException { - return (IOSElement) findElement("-ios uiautomation", using); + return findElement("-ios uiautomation", using); } /** @@ -45,12 +42,7 @@ public class IOSElement extends MobileElement */ @Override public List findElementsByIosUIAutomation(String using) throws WebDriverException { - List result = new ArrayList(); - List found = findElements("-ios uiautomation", using); - for (WebElement e : found) { - result.add((IOSElement) e); - } - return result; + return findElements("-ios uiautomation", using); } /**