Attempting to open the login page and log in, at which point the link ending in server_id=...
will be available, which is a panel to edit my server listing, where I then want to click the Update button at the bottom. Am I using By
properly?
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
driver = webdriver.Chrome(executable_path='C:/bin/chromedriver.exe')
driver.get('https://minecraft-server-list.com/login/login.php')
WebDriverWait(driver, 3).until(
expected_conditions.text_to_be_present_in_element(
By.NAME, 'username') or
expected_conditions.text_to_be_present_in_element(
By.CLASS_NAME, 'column-heading'))
if expected_conditions.text_to_be_present_in_element(
By.NAME, 'username'):
user = driver.find_element_by_name('username')
pw = driver.find_element_by_name('password')
user.clear()
user.send_keys('redacted')
pw.clear()
pw.send_keys('redacted')
driver.find_element_by_name('Submit').click()
WebDriverWait(driver, 3).until(
expected_conditions.text_to_be_present_in_element(
By.CLASS_NAME, 'column-heading'))
driver.get('https://minecraft-server-list.com/login/edit_server.php?server_id=redacted')
WebDriverWait(driver, 3).until(
expected_conditions.text_to_be_present_in_element(
By.CLASS_NAME, 'serverdatadiv1'))
driver.find_element_by_name('button').click()
driver.quit()
elif expected_conditions.text_to_be_present_in_element(
By.CLASS_NAME, 'column-heading'):
driver.get('https://minecraft-server-list.com/login/edit_server.php?server_id=redacted')
WebDriverWait(driver, 3).until(
expected_conditions.text_to_be_present_in_element(
By.CLASS_NAME, 'serverdatadiv1'))
driver.find_element_by_name('button').click()
driver.quit()
driver.quit()
Full error:
Traceback (most recent call last):
File "C:/Users/veggie/Desktop/devshit/projects/mcslUpdater/main.py", line 14, in <module>
By.CLASS_NAME, 'column-heading'))
File "C:\Users\veggie\Anaconda3\lib\site-packages\selenium\webdriver\support\wait.py", line 71, in until
value = method(self._driver)
File "C:\Users\veggie\Anaconda3\lib\site-packages\selenium\webdriver\support\expected_conditions.py", line 209, in __call__
element_text = _find_element(driver, self.locator).text
File "C:\Users\veggie\Anaconda3\lib\site-packages\selenium\webdriver\support\expected_conditions.py", line 411, in _find_element
return driver.find_element(*by)
TypeError: find_element() takes from 1 to 3 positional arguments but 5 were given