Skip to content

Commit 0c0d458

Browse files
authored
[py]: use By class attributes instead of strings (#15402)
1 parent f5cfd43 commit 0c0d458

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

py/selenium/webdriver/remote/locator_converter.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
from selenium.webdriver.common.by import By
1718

1819

1920
class LocatorConverter:
2021
def convert(self, by, value):
2122
# Default conversion logic
22-
if by == "id":
23-
return "css selector", f'[id="{value}"]'
24-
elif by == "class name":
25-
return "css selector", f".{value}"
26-
elif by == "name":
27-
return "css selector", f'[name="{value}"]'
23+
if by == By.ID:
24+
return By.CSS_SELECTOR, f'[id="{value}"]'
25+
elif by == By.CLASS_NAME:
26+
return By.CSS_SELECTOR, f".{value}"
27+
elif by == By.NAME:
28+
return By.CSS_SELECTOR, f'[name="{value}"]'
2829
return by, value

0 commit comments

Comments
 (0)