How to click on a board on trello with selenium+chrome+vba? - excel

I want to automate some functions that I usually do on Trello, like create boards and lists.
I downloaded selenium IDE from chrome. Now, I can enter on trello's website and login with my password.
But I don't know how to click on a board.
I have a ul list and I want to find the board by name and click.
Public Sub seleniumtutorial()
Dim bot As New SeleniumWrapper.WebDriver
bot.Start "chrome", "https://trello.com/login"
bot.get "/"
bot.Type "name=user", "biaverly#id.uff.br"
bot.Type "name=password", "mypassword"
bot.clickAndWait "id=login"
OK UNTIL HERE
This is where I want do click
(https://scontent.fsdu13-1.fna.fbcdn.net/v/t1.15752-9/61126356_2783547018382386_4366937053661757440_n.png?_nc_cat=110&_nc_ht=scontent.fsdu13-1.fna&oh=ac6b0ac6acc49e8ca3c2bcb54d105afa&oe=5D62AC25)
and I want do find by the name
(https://scontent.fsdu13-1.fna.fbcdn.net/v/t1.15752-9/60763397_620930688408674_8385622658426863616_n.png?_nc_cat=109&_nc_ht=scontent.fsdu13-1.fna&oh=02f1f5766e149f32e1879a553c7a9d84&oe=5D9B1F82)

You can't use className for that web element bec. it's made up from diff class. instead of class, you can use css selector to locate that element.
try this css selector .boards-page-board-section .mod-no-sidebar
you can use this css selector to locate by text div[title='urtext']

Related

How to find elements in containers that open when buttons are pressed

I am using headless Firefox on Selenium and XPath Helper to identify insanely long paths to elements.
When the page initially loads, I can use XPath Helper to find the xpath of any element of interest, and selenium can find the element when given the xpath.
However, several buttons that I need to interact with on the page open menus when pressed that are either small or take up the whole "screen". No matter their size, these containers are overlaid on the original page, and although I can find their xpaths using XPath Helper, when I try to use those xpaths to find the elements using selenium, they can't be found.
I've checked, and there's no iframe funny business happening. I'm a bit stumped as to what could be happening. My guess is that the page's source code is being dynamically changed after I press the buttons that open the menu containers and when I call find_element_by_xpath on new elements in the containers, the original source is being searched, instead of the new source. Could that be it?
Any other ideas?
As a workaround, I can get around this issue by sending keystrokes to the body of the page, but I feel this solution is rather brittle and likely to fail. Would be a much more robust solution to actually specify all elements.
EDIT:
With selenium I can find the export button, but not the menu it opens.
Here is the code for the export button itself:
The element of interest for me is "Customize Export" which I have not been able to find using selenium. Here is the code for this element:
Notice the very top line of this last image (cdk-overlay-container)
Now, when I refresh the page and do NOT click the export button, the cdk-overlay-container section of the code is empty:
This suggests my that my hypothesis is correct -- that when the page loads initially, the "Customize Export" button is nowhere in the source code, but appears only after "Export" is clicked, and that selenium is using the original source code only --not the dynamically generated code that appears after clicking "Export" -- to find elements
Selenium could find the dynamic content after doing
driver.execute_script("return document.body.innerHTML")
The WebDriverWait is what you need to use to wait for a certain condition of elements. Here is an example of waiting for the elements to be clickable before the click with a timeout in 5 seconds:
wait = WebDriverWait(driver, 5)
button = wait.until(EC.element_to_be_clickable((By.XPATH, 'button xpath')))
button.click()
wait.until(EC.element_to_be_clickable((By.XPATH, 'menu xpath'))).click()
identify insanely long paths
is an anti pattern. You can try to not use XPath Helper and find xpath or selector yourself.
Update:
wait = WebDriverWait(driver, 10)
export_buttons = wait.until(EC. presence_of_all_elements_located((By.XPATH, '//button[contains(#class, "mat-menu-trigger") and contains(.="Export")]')))
print("Export button count: ", len(export_buttons))
export_button = wait.until(EC.element_to_be_clickable((By.XPATH, '//button[contains(#class, "mat-menu-trigger") and contains(.="Export")]')))
export_button.click()
cus_export_buttons = wait.until(EC. presence_of_all_elements_located((By.XPATH, '//button[contains(#class, "mat-menu-item") and contains(.="Customize Export")]')))
print("Customize Export button count: ", len(cus_export_buttons))

Can't find html element's id, name nor class

Want to automate twitter's sending images button so I can send a file with python using selenium with the send_Keys method, but can't find its id or name nor class. This is all the code that appears referent to the button:
Html twitter send images button
Note: None of the classes shown above have worked for me
You can try to use x-path, I'm using a chrome extension: https://chrome.google.com/webstore/detail/xpath-finder/ihnknokegkbpmofmafnkoadfjkhlogph?hl=en
To locate the element you want to click.
And then you can use driver.find_element_by_xpath("X-PATH").click()

Selenium can not click on one element

I am using Selenium Chromedriver and my problem looks like this:
My program is clicking element on website and a list of elements appear.
Than it is choosing one of element from list using checkbox.
Nextly it is trying to click other element but the program crashes.
When the mentioned list appear if I am clicking anywhere on website using inspect option the code of inspected element looking like this:
<div id="__selectOverlay" style="display: block;"></div>
how can I click any element from website after the list appear?
looking at the html snippet shared, "__selectOverlay" might be the overlay which comes on top of the web page(like a loading spinwheel/panel) .
To get rid of the error, you can try the following
* Wait for panel/overlay to disappear
* Close the panel , if there is a panel close button.
And then click on any element on the web page
As per the HTML you have shared the WebElement seems to me as a Overlay within a div tag. Moreover this div tag doesn't have a onClick() event associated. So we won't be able to click the WebElement straight away. Possibly you might be trying to invoke click() method on some other element which is having this temporary / permanent Overlay through the div tag.
Solution
Depending on the type of Overlay there are two possible solutions as follows :
Temporary Overlay :
In this case induce ExplicitWait with ExpectedConditions set to invisibilityOfElementLocated for the Overlay to be invisible.
WebDriverWait wait1 = new WebDriverWait(driver, 10);
wait1.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("ele_to_inv")));
Permanent Overlay :
Use JavascriptExecutor to send the click directly on the element.
WebElement ele = driver.findElement(By.xpath("element_xpath"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", ele);

Unable to click on the link using selenium and Python

Image Attached I want to click on the specific button on a webpage, using selenium webdriver and Python. Tried finding the element by CSS, class name and XPath, but it doesn't seem to work. I have attached an image showing the button I want to click (It is not a dropdown as the image suggests) and the HTML details. Any help would be appreciated.
Actually sometimes selenium is not able to interact with some web elements using click try simulating enter key press on that element for e.g. -
element = driver.find_element_by_id("value")
element.send_keys(:return)
Let me know if that works

Tool to find xpath and iframe id

I'm automating a web page which contains several nested iframes. This makes it hard for me to find the proper locator for the elements. I use firebug, the f12 tools ... to get xpath etc. but I miss something here, the iframe id.
Does someone know a tool where I can point on an element on the web page, and get the xpath and the iframe id?
THX
Firebug displays the iframes containing the inspected element within its ancestor path:
By clicking on the buttons within the ancestor path you can jump to the related iframe.
To get the XPath for an iframe right-click on it within the HTML panel and choose Copy Minimal XPath or Copy XPath from the context menu.

Resources