questions about selecting an option in dropdown menu in Selenium WebDriver - selenium-webdriver-python

I am a beginner in Selenium.
The options in the dropdown menu are in the red box below. Depending on what login ID you used to log in, the options are dynamic.
enter image description here
enter image description here
I need to select Editor. This is the code i used:
self.driver.find_element_by_xpath("//div[.//label[contains(text(),'Editor')]]//Select").click()
But it gives me an error.

Related

Unable to put number in text box in selenium

I want to put the number in the textbox and click on Get App link When I am using XPath
command:
driver.findElement(By.xpath("//*[#id="ngdialog1"]/div[2]/div/div[1]/div[1]/div[1]/input")).sendKeys("123456789");
When I run the script the popup window is opening but it does not enter the value in text box.
Please refer screenshot.
Add a wait, if necessary, as Andersson suggested, then use this xpath:
driver.findElement(By.xpath("//*[contains(local-name(), 'input') and contains(#name, 'number')]")).sendKeys("123456789");

Unable to automate a click to a dropdown box using Selenium IDE 2.9.0

I am trying to automate a drop-down box on a site but I can't get Selenium to automatically click the box. I've tried targeting all of the elements within this box and none work.
Can anybody please shed some light?
Many thanks
Try to use below code to select your required option i.e., Level Term & Critical Illness from the Drop down:
//first click on DropDown to open drop down options
WebElement dropDown = driver.findElement(By
.xpath(".//*[#id='QuoteAmend_PolicyType_chzn']/a"));
dropDown.click();
//Select second option from the drop down
driver.findElement(
By.xpath(".//*[#id='QuoteAmend_PolicyType_chzn_o_1']"))
.click();

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.

Sikuli integration with Selenium WebDriver

Can anyone tell me how to work with multiple edit boxes using Sikuli integrated Selenium WebDriver.
For example, I have 2 edit boxes which are labeled as username and password. So I want to click on the 1st edit box, then enter values and again want to click on the 2nd edit box. The size of the two edit boxes are the same. So how sikuli integrated Selenium WebDriver will identify which edit box to click.
If you are referring to the SikuliWebDriver, then this link has an example on the usage http://code.google.com/p/sikuli-api/wiki/SikuliWebDriver.
I would rather prefer using the Sikuli Java API and create wrapper functions around the Sikuli functions like click, type etc. This API is in active development and has good support available.
http://doc.sikuli.org/faq/030-java-dev.html
You can use the offset functionality. ie, you do not only use an image of the text field, but use a region of the screen which identifies something related to the text fields.
You may select a large rectangle which includes a heading above both fields, then use offset x/y coordinates and move the little crosshair over the exact location you wish to click/type.

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

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.