automatic date picking selenium - selenium

I am working on automating some web related task. For that I am using selenium. However, After trying hours I could not figure out to automate date picking. I have two calendars. See the figure to understand better.
[
What I am trying to achieve is to choose two dates from the left and right calendar. I want to send two dates and set those dates( also month and year) on those two calendars. I tried to do something like that. I took the xpath for "k-calendar k-first-month" class.
calender_left = driver.find_element_by_xpath('//*[#id="filter-section-timeFilters"]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div[1]')
ActionChains(driver).move_to_element(calender_left).click().send_keys('02/12/20').perform()
However, no luck on that.
This is how the css elements looks like for the left calendar.
Update: I decided to click month and year button using xPath.

Is there any input field to enter date through keyboard?
If YES take xPath or clasName or cssSelector of that element and use sendkeys.
Refer the link https://www.browserstack.com/guide/datepicker-in-selenium it will be helpfull.

Related

VBA to find if an element contains certain texts

I'm new to Selenium and VBA.
What i want to do is automate selection of a certain TEXT in a CSS.
Selenium brings me this:
css=.x-grid3-row:nth-child(42) .x-grid3-col:nth-child(4) > .x-grid3-cell-inner
Everyting would be fine, except the TEXT I want to select sometimes move to different grid3-row:nth-child
What I want to achieve is to find in which x-grid3-row:nth-child the desired TEXT is so I could click it with a VBA bot.
Thank you for your help.
You won't be able to construct a css-selectors passing the desired text.
You can find a relevant detailed discussion in selenium.common.exceptions.InvalidSelectorException with “span:contains('string')”
As an alternative you can use a xpath based Locator Strategy as follows:
driver.FindElementByXPath("//*[#class='x-grid3-cell-inner' and text()='certain_text']")

Appium how to find and get the text of an element that changes such as a user's balance

I'm trying to find the element on my app that shows the balance text of how much a user has.
The element does not have a content-desc and the text can easily change because it's the user's balance.
Could anyone show me different methods of how I can get the balance text with this?
You would have to go with xpath here. Say find all the text views and either get this element by index, or search for a one which starts with $ or something.
If its an app that is being developed, then its a good idea to check with developers to add content-desc here.

Not able to identify Elements inside the Android Calendar picker using Appium or using uiautomatorviewer

can any one help me to resolve android calendar picker selection issues.
I want to select desired date(DD-MM-YYYY) for my automation project.
UI automator recognized entire calendar as one element and unable to get child elements details/unable to get date elements in UI automator viewer.(Screenshot attached for your reference)
Kindly do the needful.
Android Calendar Picker UIautomator screens shot
We had the same scenario like this in one of our apps.
When a date is selected from the date selector the date will be inserted in to a text box. But the selection could not be done through the calendar ui.
As a solution we fired a date_textFieldElement.sendKeys("10-14-2015") command in to the date text field.
That did the trick.

How to type data into table rows in selenium ide?

Right now I am trying to use selenium ide to write code that makes sure web pages on a website work. On one particular page there is a table that has text boxes in each cell. You can add a row by clicking a button. What I want to do on this page is type data into the first two rows. I used selenium ide and recorded me typing in data. Then I tried to replay it. It worked fine until it came to the second row. The second row it could not write data to. The first row text boxes had targets of terms[] and defs[] . the second row looks the exact same but has targets of //td[#id='autoDefinerTd']/textarea and //table[#id='termList']/tbody/tr[3]/td[3]/textarea . I am completely stumped on what to do to fix this and why they are different. If someone could help me I would be so grateful.
Thanks in adavnce.
I figured out you just do it the normal way. For some reason selenium was doing it a weird way.

Selenium Automated Testing and java textboxes

Hey Ive tried looking for how to solve this for a couple hours and I keep coming up blank.
Im using Selenium IDE to try and make a few simple Automated tests (basically the test will access the site, create content and submit it, to ensure that it still works)
But there is a part of the site that is a javascript text box and i need to enter text into it.
However Selenium doesn't recognize any actions I make inside the text editing section of the box. It will recognize if I press something like BOLD or ITALICS.
When I select BOLD it returns: click | //a[#id='mce_editor_1_bold']/img |
But like i said, it wont recognize when I select the text editing part of the box.
I tried using xpath (and firebug) after some research online, but I cant seem to make that work.
Anybody have help or ideas to offer?
You can also use javascript to work with Selenium. So for example, if your rich text box has id="RichText" you can obtain the element via javascript and input your value there.
The code looks something like this:
| verifyEval | javascript{this.browserbot.getCurrentWindow().document.getElementById('RichText').value = 'Foo Bar'} ||
However, I've found that the syntax can vary for the this.browserbot portion. It will take a bit of work to get things going. You can also checkout this article from The Automated Tester which has information on what you're trying to do.
Also this question should help you out further: Selenium: How do I use javascript to clear a value from a form field?
I would recommend persevering with Firebug. Open the page that your testing and use Firebug's 'Inspect' feature to locate the text box in the HTML source. Then you should be able to find a way to locate the box using id, xpath, or css.
For example:
If it has id='textBox' you can locate it using id=textbox.
If it has class='jsTextBox' you can locate it using css=.jsTextBox
Otherwise you can use XPath - I'd recommend getting the XPath Checker extension so you can right click the text box and find out the XPath. You might want to play around with the result to make it a smarter XPath though.
Once you've found out the location you should be able to input data using the type or typeKeys commands. type changes the value, and typeKeys fires key up/down for each character - it's slower but sometimes needed depending on the application under test.
type | id=textBox | myValue
verifyValue | id=textBox | myValue
Hope this helps,
Dave.