providing this to scroll , then click on the element which text value i am declared in description
AndroidElement quot=(AndroidElement)driver.findElementById("com.mrk.compaq.application:id/divider21");
MobileElement list = (MobileElement) driver.findElement(
MobileBy.AndroidUIAutomator(
"new UiScrollable(new UiSelector()).scrollIntoView("
+"new UiSelector().description(\"*Enter UTR No.*\"));"));
System.out.println(list.getLocation());
//list.click();
but the result is its scrolling up and down but not able to click on the element .
Your click line is commented out.
Uncomment it: //list.click(); -> list.click();
Related
<div class="et_pb_button_module_wrapper et_pb_button_4_tb_header_wrapper et_pb_button_alignment_center et_pb_button_alignment_phone_center et_pb_module ">
<a class="et_pb_button et_pb_button_4_tb_header full-width-btn et_hover_enabled et_pb_bg_layout_light" href="https://pegramonline.com/compare-insurance-companies-charlotte-nc/">Get a Quote</a>
</div>
I tried to locate <a> element and still it could not locate it..any other suggestion please...the class name has a space
By.cssSelector(“a[class=’et_pb_button et_pb_button_4_tb_header full-width-btn et_hover_enabled et_pb_bg_layout_light’]”);
By.cssSelector(“a.et_pb_button.et_pb_button_4_tb_header.full-width-btn.et_hover_enabled.et_pb_bg_layout_light”);
By.xpath(“//a[contains(#class, ‘et_pb_button’) and contains(#class, ‘et_pb_button_4_tb_header') and contains(#class, ‘full-width-btn')
and contains(#class, ‘et_hover_enabled’) and contains(#class, ‘et_pb_bg_layout_light’)]”);
It is working fine if you try to put a property color or anything else in this CODE
a.et_pb_button.et_pb_button_4_tb_header.full-width-btn.et_hover_enabled.et_pb_bg_layout_light{
color:red;
}
Or
a[class=’et_pb_button et_pb_button_4_tb_header full-width-btn et_hover_enabled et_pb_bg_layout_light’]{
color:red;
}
then you can easily understand that it's working fine.
There are 4 ways to click in Selenium.
Use the below xpath
//a[contains(text(),'Get a Quote')]
Code trial 1 :
Thread.sleep(5);
driver.findElement(By.xpath("//a[contains(text(),'Get a Quote')]")).click();
Code trial 2 :
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//a[contains(text(),'Get a Quote')]"))).click();
Code trial 3 :
Thread.sleep(5);
WebElement button = driver.findElement(By.xpath("//a[contains(text(),'Get a Quote')]"));
((JavascriptExecutor)driver).executeScript("arguments[0].click();", button);
Code trial 4 :
Thread.sleep(5);
WebElement button = driver.findElement(By.xpath("//a[contains(text(),'Get a Quote')]"));
new Actions(driver).moveToElement(button).click().build().perform();
PS : Please check in the dev tools (Google chrome) if we have unique entry in HTML DOM or not.
Steps to check:
Press F12 in Chrome -> go to element section -> do a CTRL + F -> then paste the xpath and see, if your desired element is getting highlighted with 1/1 matching node.
First time Posting on this site. I hope I have the information formatted correctly.
I am designing a simple windows form to help create change control forms to track employee access. It is a 2 part form. The main form asks for some user input and there is a checkbox at the bottom that they can select if they are requesting a standard user setup. When they click next in the main form a child form window pops up that contains a treeview and a comments section for any special notes. What I am trying to do is have some nodes automatically checked if the 'Standard Setup' box is checked in the main form.
When I run the code I get a error stating "Method invocation failed because First[System.Windows.Forms.TreeView] does not contain a method named 'checknode'."
My standard setup box is $checkboxStandardSetup and if it has been checked then I want to have it place a checkbox next to these nodes in the treeview. If it isn't checked no other modification need to be made in the treeview. Here is a snippet of what I have.
if ($checkboxStandardSetup.Checked)
{
$treeview1.checknode("7")
$treeview1.checknode("8")
$treeview1.checknode("9")
$treeview1.checknode("10")
$treeview1.checknode("11")
$treeview1.checknode("12")
$treeview1.checknode("14")
$treeview1.checknode("20")
}
I have also tried to use
if ($checkboxStandardSetup.Checked)
{
$treeview1.node7.checked
$treeview1.node8.checked
$treeview1.node9.checked
$treeview1.node10.checked
$treeview1.node11.checked
$treeview1.node12.checked
$treeview1.node14.checked
$treeview1.node20.checked
}
But to no avail. The function below works to parse through and then output a list of the checked nodes but I can't get the standard setup box to apply those checks.
Function Get-CheckedNodes
{
param (
[ValidateNotNull()]
[System.Windows.Forms.TreeNodeCollection]$NodeCollection,
[ValidateNotNull()]
[System.Collections.ArrayList]$CheckedNodes)
foreach ($Node in $NodeCollection)
{
if ($Node.Checked)
{
[void]$CheckedNodes.Add($Node)
}
Get-CheckedNodes $Node.Nodes $CheckedNodes
}
}
To call the function I use
$checkedNodes = New-Object System.Collections.ArrayList
Get-CheckedNodes $treeview1.Nodes $CheckedNodes
foreach ($node in $CheckedNodes)
{
Write-Output $node.text | Out-File -append C:\Change\UserForm$(Get-Date -Format 'MM-dd-yy').csv
}
I expected the treeview list to have a checkbox next to the nodes that I coded but instead I get the above error. I don't understand what I am doing wrong. Any advice appreciated!
What i'm trying to achieve is that when a popup is displayed, the input panel (keyboard) appears as well, and when the user start typing it also update the entry content that is on the panel content.
Unfortunately this appear to be quite complex in Tizen.
What I obtained so far is that the popup is displayed, the kepad too, but when I press buttons on the keypad they are not updating the entry.
In order to start real typing even if the keypad is displayed, i have to tap on the entry.
I did many different tries, without success. The following is the first version of the code and i try to list all the changes i tested:
Evas_Object *popup, *layout;
popup = elm_popup_add(parent);
elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_part_text_set(popup, "title,text", "Use energy");
layout = elm_layout_add(popup);
elm_layout_theme_set(layout, "layout", "drawer", "panel");
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_content_set(popup, layout);
Evas_Object *entry = elm_entry_add(layout);
set_number_on_entry(entry, 0);
elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_NUMBERONLY);
elm_entry_input_panel_show(entry);
elm_object_part_content_set(layout, "elm.swallow.content" , entry);
dlog_print(DLOG_INFO, APP_TAG, elm_entry_entry_get(entry));
container->entry = entry;
Evas_Object *button1;
button1 = elm_button_add(popup);
elm_object_text_set(button1, "OK");
elm_object_part_content_set(popup, "button1", button1);
elm_object_style_set(button1, "popup");
evas_object_smart_callback_add(button1, "clicked", ok_pressed_energy, container);
/* Add a "Cancel" button to popup */
button1 = elm_button_add(popup);
elm_object_text_set(button1, "Cancel");
elm_object_part_content_set(popup, "button2", button1);
evas_object_smart_callback_add(button1, "clicked", dismissed_cb, popup);
evas_object_smart_callback_add(popup, "dismissed", dismissed_cb, NULL);
container->popup = popup;
evas_object_show(popup);
elm_object_focus_set(entry, EINA_TRUE);
elm_entry_cursor_end_set(entry);
The first version of the code (the one above) was trying to display the panel while the popup was still creating. So maybe the show call could have impacted on the focus status for the entry.
The following are the changes i tried in order:
I tried to explicitly allow the focus on the entry using:
elm_object_focus_allow_set(entry, EINA_TRUE);
without luck. I also tried to explicitly give the focus to the entry just after the focus allow was set to true, again no success.
I tried to show the panel after the entry was focused (then after the show function for popup was called. Again not working.
Added:
elm_entry_input_panel_enabled_set(entry, EINA_TRUE);
The documentation for that function says:
If true, the input panel is appeared when entry is clicked or has a focus.
Not working
Tried to display the code using the context obtained from the entry with the following code:
Ecore_IMF_Context *imf_context = (Ecore_IMF_Context*)
elm_entry_imf_context_get(entry);
if(imf_context){
dlog_print(DLOG_INFO, APP_TAG , "Imf context");
ecore_imf_context_input_panel_show(imf_context);
}
I tried to post the question also on the Tizen foru, but i still didn't get an answer that solve my problem, this is the link: https://developer.tizen.org/forums/native-application-development/entry-on-popup-focus#comment-27748
What i'm doing wrong? I tried everything but at the moment with no luck. And unfortunately the documentation is not covering this use case (that i think is quite common).
Any help?
I am trying to click on 'New Trade' link which is in span n6 which is a child element of span n2. I am able to reach till n2 but its not identifying 'n6'.
Please help I am new to Selenium WebDriver
Here I am posting the html and my code.
Trading
New
Trade
Trade
Explorer
I want to click on New Trade
HTML source code
My code which went till span 'n2':
driver.switchTo().frame(driver.findElement(By.name("treeFrame")));
WebElement allFormChildElements = driver.findElement(By.name("the_form"));
allFormChildElements.findElement(By.linkText("Trading")).click();
WebElement modalDialog = allFormChildElements.findElement(By.className("border"));
WebElement newmodalDialog = modalDialog.findElement(By.className("formScrollableMenuContent"));
System.out.println(newmodalDialog.findElements(By.tagName("a")).size()); // ans 5
WebElement newDialog= newmodalDialog.findElement(By.id("n2"));
System.out.println(newDialog.findElements(By.id("n3")).size()); // ans 0
With the image I can't test but, if you are able to reach the element <span id="n2">, from there you could use the following xpath in order to click the element with the text "New Trade":
newDialog.findElement(By.xpath(".//span[#id='n6']/a[#name='A6' and text()='New Trade']")).click();
EDIT
If the id value change, try in this way:
newDialog.findElement(By.xpath(".//span/a[#name='A6' and text()='New Trade']")).click();
Could you please try below xpath
//a[contains(text(),"New Trade")]
I use an instance of UITextField in which the text is normally aligned to the right, but switches to left alignment when being edited. This is done by calling setTextAlignment: on the editingDidBegin event. Since the update to iOS 6 this behaves strangely: The text alignment is changed correctly from right to left, but the cursor remains at the far right of the text field until some input is performed.
Does anybody know how to restore the expected behaviour so that the cursor moves as well when the alignment is changed?
To give some context: I use the text field to show a value with a unit. The unit is removed during editing and then displayed again after the user hits enter.
Method called on event editingDidBegin:
- (IBAction)textEditingDidBegin:(UITextField *)sender
{
[sender setTextAlignment:NSTextAlignmentLeft];
[sender setText:[NSString stringWithFormat:#"%.0f", width]];
}
Method called on event editingDidEnd:
- (IBAction)textEditingDidEnd:(id)sender
{
[sender setTextAlignment:UITextAlignmentRight];
[sender setText:[NSString stringWithFormat:#"%.0f m", width]];
}
Try resigning the textView as first responder, then make it first responder right after that.
textView.textAlignment = NSTextAlignmentCenter;
[textView resignFirstResponder];
[textView becomeFirstResponder];
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
textField.textAlignment = NSTextAlignmentLeft ;
return YES ;
}
Change the textAlignment before editing did begin. The best place I know to do this is in the UITextFieldDelegate method textFieldShouldBeginEditing.