Webdriver: Click on button's part for open color chooser - selenium

I use Selenium to test some web-product in my company.
Product has button, which open dialog to choose color. I think it's created using 'extJS' (I'm not so sure).
But then i click to any part of that button, using Webdriver, it's always just set current selected color, but newer opened dialog window to select color.
I found similar button on some random site, which has similiar behavior.
Link to site with button on developer.yahoo.com
So in source of the page you can see, that there is no specific element for right part of button, with down-oriented arrow.
So xPath
//*[#id='color-picker-button']
describe button in all,right part and left part.
But every child element of this describe only left part of this button, so right part with arrow has no any specific xPath to click in my WebDriver text.
I also tried things like
driver.action.move_to(element, coordinate_right, coordinate_down).perform
but it has no effect for me.
So in general my question is :
How to open color selector window on that Yahoo page

Use the SendKeys() method and send the "down arrow" key to the control (C#):
element.SendKeys(Keys.ArrowDown);
That should open it right up.

Related

How to inspect an element created dynamically in the DOM for karate testing

I’m working on an application that allows you to enter an automatic date. To test this application, I must follow a scenario that allows to select a specific date (e.g: 15/12/2021) by clicking on it.
For this I use a datepicker from the bootstrap library.
datepicker
But it is impossible to inspect this element, because, once displayed, it disappears with the slightest mouse click in the window, so that when I right-click on the datepicker to inspect it I lose the focus on the element that disappears.
Here's the inspector (when I want to open the div, the datepicker disappears):
inspector HTML code
How could I inspect this datepicker to create selectors?
Best regards
Use Chrome:
1. Right click Inspect
2. Go to Elements tab
3. Click on datepicker element (and watch what element is highlighted in the Elements tab)
4.Right click on that element in Elements tab and select Brake on - one of the options should work
5. Click on that datepicke element and Debugger should start
6. Click on Play until Your element is loaded
7. Inspect
For example:
Go to google.com
To inspect google apps selection:
1. Inspect page and switch to Elements tab
2. After clicking App selection button you will see that class="fade-in" is highlighted
3. Right click on this element in Elements tab and select Brake on - > attribute modification
4. Click on App selection again and You will see debugger appear
https://ibb.co/D7V3P3C
5. Click on Resume script execution but in the Inspector (Red bounding box on the pic) not on Debugger in main screen, until App selection is not showed
6. Then You can inspect Apps as You wish
You could also use EventListeners to set break on them.

Unable to click on element in menu

I am not able to click on the button, how you can see on the picture. This menu is visible, when you click on Tabellen button in the main menu. It is working manually, but when I try my selenium code, it is not working. I try different type of select it, I tried also waits. I tried xpath, cssSelector, ID. What is strange, selenium just click Tabellen button from main menu, but that menu after that just blink and nothing happen.
Please use this example. You need to correct XPath if I have made a mistake.
driver.find_element_by_xpath('//*[text()="Tabellen"]').click()
time.sleep(5)
driver.find_element_by_xpath('//*[text()="Tabellen"]//*[text()="Standorte"]').click()

How can I reach the elements of the appeared pop-up using selenium?

In the following ecommerce site "https://www.gittigidiyor.com/", I want to click on "giris yap" button using selenium java but the problem is whenever I hover the mouse to profile icon, this pop-up appears and i try to inspect the pop-up to see the element but nothing happened. Could you please help me how can i click the buttons of this pop-up. I tried by switching to alert/frame but it did not workopened login popup in the site
driver.get("https://www.gittigidiyor.com")
driver.findElement(By.cssSelector("[title=\"Giriş Yap\"]")).click()
WebDriverWait wait = new WebDriverWait(driver,30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("[data-cy=\"header-login-button\"]"))).click();
To find the element use below technique:
To search xpath of such dynamic elements use DOM break points:
And select break on subtree modification. Now all changes will break and pause the webpage rendering
Click resume execution or press f8 till your span gets displayed

How to click on the text after scroll down in Selenium IDE

The web page that I am using has a list of links
My use case is to perform page down operation and select the link at that location.
I performed page down using the following command
storeEval with the Target as selenium.browserbot.getCurrentWindow().scrollTo(0,20000)
The above action performs the page down
My next action is to click the link that is shown
I used the command clickAtAndWait with the target link=target_link
The above action clicks the text target_link at the top of the page (which is not visible) and not the text that is visible.
I need to perform page down and click the text target_link that is visible.
What change needs to be performed for this action?
In the Selenium IDE you can use the Command focus with a Target value of an element at the bottom of your page.
For example:
Command: focus
Target: id=nextButton1
Value:
This will scroll the Selenium IDE (Firefox) window down so the "Next Button" is just visible at the bottom of the screen. The Value parameter is not used and has been left blank.
You need to find the element and then use the click command.
Sample code:
elem1 = driver.find_element_by_class_name("wtb-search-submit")
elem1.click()
Read at http://selenium-python.readthedocs.org/en/latest/locating-elements.html on how you can locate the element. Hope it helps.

Use of 'ClickAt ' selenium command

I'm confused about the difference between the Click and ClickAt commands in selenium. Where can I use the ClickAt command?
Here are what Selenium IDE says about those two commands :
click(locator) Arguments:
locator : an element locator
Clicks on a link, button, checkbox or
radio button. If the click action
causes a new page to load (like a link
usually does), call waitForPageToLoad.
And :
clickAt(locator, coordString) Arguments:
locator : an element locator
coordString : specifies the x,y position (i.e. - 10,20) of the mouse
event relative to the element returned
by the locator.
Clicks on a link, button, checkbox or
radio button. If the click action
causes a new page to load (like a link
usually does), call waitForPageToLoad.
click is used when you just want to "click" on an element, like a button, a link, ...
And clickAt is used when you want to "click" on a position designated by mouse coordinates.
I suppose the second one can be useful for some "rich" applications -- I've actually never used it... On the other hand, I use click like all the time.
If you have a page with form elements, links, buttons, and stuff like that, you'll probably generally use click : it's way easier to find an element using it's id or classname than having to find it's position in pixels on the page ^^
I noticed some differences between click() and clickAt() when testing a ExtJS app.
For example, if I try to click a tab in a Ext.TabPanel, click() command does not work, although I provide it with an correct xpath, and clickAt() works fine.
Code looks like this:
click("//li[#id='tab-panel-id__second-tab-id']/a[2]/em/span/span")
doesn't work, but
clickAt("//li[#id='tab-panel-id__second-tab-id']/a[2]/em/span/span","0,0")
works.
Notice that coordinates are (0,0)
I can't figure out why this happens...
I'm testing a GWT application and it seems like I have to use clickAt if I want to click on a node in a tree widget.
Be careful when testing clickAt. Sometimes double clicking the command will cause it to show up red. You will change the line to try other alternatives but nothing will work. But then run your script and the clickAt line will be fine with whatever you type in.
There is a dojo widget at our application which only works with clickAt("//span[#id='mastheadIconBar']/span[1]/span/span","0,0").
Don't know why, but only click("//span[#id='mastheadIconBar']/span[1]/span/span") does not work.