This question already has answers here:
Selenium Select - Selecting dropdown option by part of the text
(8 answers)
Closed 6 years ago.
id of drop down = "rw_520631"
Value which I want to select from drop down is = "Automation RW (0/6)"
Now here "Automation RW" is static but "(0/6)" can change.
How can I select this using selenium webdriver in JAVA
This question was answered here - Selenium Select - Selecting dropdown option by part of the text
Below is the snippet of the answer:
List <WebElements> optionsInnerText= driver.findElements(By.tagName("option"));
for(WebElement text: optionsInnerText){
String textContent = text.getAttribute("textContent");
if(textContent.toLowerCase.contains(expectedText.toLowerCase))
select.selectByPartOfVisibleText(expectedText);
}
Related
This question already has answers here:
How to resolve ElementNotInteractableException: Element is not visible in Selenium webdriver?
(6 answers)
org.openqa.selenium.ElementNotInteractableException: Element is not reachable by keyboard: while sending text to FirstName field in Facebook
(5 answers)
Selenium WebDriver throws Exception in thread "main" org.openqa.selenium.ElementNotInteractableException
(1 answer)
Closed 2 years ago.
This is the DOM structure.
DOM
Any of the following operations are throwing org.openqa.selenium.ElementNotInteractableException
selectFileStatus.selectByIndex(2);
Or
selectFileStatus.selectByVisibleText(valueToSelect);
The instantiation is like this.
Select selectFileStatus = new Select(wait.until(ExpectedConditions.elementToBeClickable(By.xpath(
property.getPropertyObject(propFileDetailClaimReview).getProperty(propertyDropdownFileStatus)))));
And the XPATH is tested in browser.
//span[contains(text(), 'File Status')]/parent::label/following-sibling::select
Interestingly, a read operation is working fine.
List<WebElement> allOptions = selectFileStatus.getOptions();
System.out.println("*** Values of the dropdown...");
for(WebElement eachOption : allOptions)
System.out.println(eachOption.getText());
As this <select> tag looks like a real HTML object, what can be the problem here?
Note: Tried JS injection, and it did nothing actually (I expected it to expand the dropdown).
WebElement ele = driver.findElement(By.xpath(
property.getPropertyObject(propFileDetailClaimReview).getProperty(propertyDropdownFileStatus)));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", ele);
This question already has answers here:
how to get field page in PDFBox API 2?
(1 answer)
how to know if a field is on a particular page?
(4 answers)
Closed 2 years ago.
If I have a 2 page pdf document with a signature field (signature1), how can I parse the document using pdfBox to find which page contains the signature field (either blank or signed).
OR how can I find the page No for signature1 in a multi page pdf document?
I can successfully add a signature field to page 2:
page = doc.getPage(1)
widget = signatureField.getWidgets().get(0)
widget.setAppearance(appearanceDictionary)
widget.setRectangle(rect)
//set it to page 2
widget.setPage(page)
from code example:
https://www.programcreek.com/java-api-examples/?api=org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField
assuming you have the widget and it is not null:
PDPage signaturePage = widget.getPage();
int pageIndex = document.getPages().indexOf(signaturePage);
now you have the 0-based page number.
This question already has answers here:
getWindowHandles() not working in firefox 58.The focus remains on parent tab and does not transfer to next tab
(2 answers)
Best way to keep track and iterate through tabs and windows using WindowHandles using Selenium
(1 answer)
Closed 3 years ago.
I am trying to automate a test case using Java, Selenium and Chrome Driver but I have not been able to navigate to the newly opened tab. I can see that the page opens but Selenium's focus does not move to the new tab.
I have tried a number of things: each of these points were tried on their own
driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL, Keys.PAGE_DOWN);
element = driver.switch_to_window(element.driver.window_handles[1]);
element.sendKeys(Keys.CONTROL +"\t");
new Actions(driver).sendKeys(driver.findElement(By.tagName("html")), Keys.CONTROL).sendKeys(driver.findElement(By.tagName("html")),Keys.NUMPAD2).build().perform();
element = driver.findElement(By.xpath("//bdi[contains(text(),'Open SQL Console')]"));
ScriptUtils.waitFor(DELAY);
supa.startMeasurement("40_Open_SQL_Console");
element.click();
System.out.println("Step 40 " );
ScriptUtils.waitFor(DELAY);
``` java
element = driver.switch_to_window(element.driver.window_handles[1]);
element.sendKeys(Keys.CONTROL +"\t");
new Actions(driver).sendKeys(driver.findElement(By.tagName("html")), Keys.CONTROL).sendKeys(driver.findElement(By.tagName("html")),Keys.NUMPAD2).build().perform();
I have even tried to go directly to the page but without luck.
driver.get ("https://mo-xxxx.mo.xxxx.corp:51043/xxxx/xxxxxa/cst/catalog/index.html?target=sqlconsole&databaseid=C119");
I can tell that I am on the same page because I can find an element on the current page.
org.openqa.selenium.NoSuchElementException: no such element: Unable to
locate element:
{"method":"xpath","selector":"//*[contains(#data-xxxx-ui,
'__editor')]"}
The element can easily be found outside of java/selenium so I know it is there.
This question already has answers here:
Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click
(9 answers)
Closed 4 years ago.
I'm trying to click a button. I tried the CSS, XPath and ClassName locators. I'm getting a "unknown error: Element is not clickable at point" error
WebDriverWait wait4 = new WebDriverWait (driver, 15);
wait4.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#get-
quote-enabled > fieldset > a"))).click();
Try using 'Actions' object:
Actions actions = new Actions(driver);
WebElement webelement = By.cssSelector("#get-
quote-enabled > fieldset > a");
actions.moveToElement(webelement).click().perform();
Trying to select Gender in Gmail registration page.. Clicking on Gender is opening a DIV with 3 options.. I was able to find the options using xpath and also capture the text or tagname.. but, click is not working
baseURL = "http://www.gmail.com";
driver.get(baseURL);
driver.findElement(By.id("link-signup")).click();
driver.findElement(By.id("Gender")).click();
Thread.sleep(1000);
driver.findElement(By.xpath("//div[#id='Gender']//div[#class='goog-menu goog-menu-vertical']//div[#id=':e']")).click();
The Gender in Gmail registration page is a dropdown. So, you need to wrap your WebElement into Select object and then select its option.
Following code may help you.
//Identify dropdown
Select gen= new Select(driver.findElement(By.id("Gender")));
//select its option.
gen.selectByVisibleText("Male");//provide value that you want to select here.
OR
gen.selectByIndex(1); // provide value's id here.
OR
gen.selectByValue("Ma");//provide value here.