forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelenium.qll
More file actions
36 lines (31 loc) · 1.08 KB
/
Selenium.qll
File metadata and controls
36 lines (31 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Provides classes and predicates for identifying classes reflectively constructed by Selenium using the
* `PageFactory.initElements(...)` method.
*/
import default
import semmle.code.java.Reflection
/**
* The Selenium `PageFactory` class used to create page objects
*/
class SeleniumPageFactory extends Class {
SeleniumPageFactory() { hasQualifiedName("org.openqa.selenium.support", "PageFactory") }
}
/**
* A call to the Selenium `PageFactory.initElements` method, to construct a page object.
*/
class SeleniumInitElementsAccess extends MethodAccess {
SeleniumInitElementsAccess() {
getMethod().getDeclaringType() instanceof SeleniumPageFactory and
getMethod().hasName("initElements")
}
/**
* Gets the class that is initialized by this call..
*/
Class getInitClass() { result = inferClassParameterType(getArgument(1)) }
}
/**
* A class which is constructed by Selenium as a page object using `PageFactory.initElements(...)`.
*/
class SeleniumPageObject extends Class {
SeleniumPageObject() { exists(SeleniumInitElementsAccess init | this = init.getInitClass()) }
}