GUI with pyqt5 QLineEdit using Web driver Script

0 votes

I am currently working on a GUI with PyQt5 and attempting to connect it with my selenium web-driver script. I have connected the button to run the script but the problem is script goes into a shopping website and checks out Items for you sizes.I have put in variables inside the script and text boxes inside the GUI.I want to be able to type In the size into the QLineEdit and have the script choose it here is an example of my script.

self.Start_Button_2 = QtWidgets.QPushButton(self.Window_2)

self.Start_Button_2.setGeometry(QtCore.QRect(100, 370, 221, 51))

self.Start_Button_2.setAutoFillBackground(False)

self.Start_Button_2.setObjectName("Start_Button_2")

self.Start_Button_2.clicked.connect(self.BOT)

 

and then I define the bot below:

def BOT(self):

        from selenium import webdriver

        from selenium.webdriver.support.ui import WebDriverWait

        from selenium.webdriver.support import expected_conditions as EC

        from selenium.webdriver.common.by import By

        from selenium.webdriver.support.select import Select

        from selenium.common.exceptions import NoSuchElementException

        import time

 

 

        driver = webdriver.Chrome(executable_path='/Users

        URL = .....

        driver.get(URL)

 

        select = Select(driver.find_element_by_id('s'))

        #select.select_by_visible_text(Size)

 

I have text boxes for size that the user puts in and

    self.Item_Code_2 = QtWidgets.QLineEdit(self.Window_2)

    self.Item_Code_2.setGeometry(QtCore.QRect(20, 40, 125, 21))

    self.Item_Code_2.setObjectName("Item_Code_2")

    self.Name_2 = QtWidgets.QLineEdit(self.Window_2)

I tried size = self.Item_Code_2.text but it is not working. Help me how to connect a text box into a function script?

Jul 23, 2018 in Selenium by Martin
• 4,220 points
60 views

1 answer to this question.

0 votes

For a QLineEdit you use the your variable then the self.(the name of it) then .text() So in your case it would be Item_code = (self.Item_Code_2.text()) For combo boxes you would use .currentText() So if you had a combo box for Sizes and stiff it would be Size = (self.Size_2.currentText())

Item_code = (self.Item_Code_2.text())

Size = (self.Size_2.currentText())

answered Jul 23, 2018 by Samarpit
• 5,130 points

Related Questions In Selenium

0 votes
1 answer

Selenium 2.0 web driver Tutorials using .NET

Docs here have an example in C#: http://seleniumhq.org/docs/03_webdriver.html using ...READ MORE

answered Apr 20, 2018 in Selenium by Vardy
• 2,280 points
12 views
0 votes
1 answer

To check that the web page is loaded or not using Selenium Web Driver?

The solution is using Implicit Wait which ...READ MORE

answered May 24, 2018 in Selenium by Meci Matt
• 9,400 points
3,810 views
0 votes
2 answers

Get text using selenium web driver in python

text = driver.find_element_by_class_name("current-text").getText(); READ MORE

answered Feb 4 in Selenium by anonymous
7,991 views
0 votes
1 answer

Popup messages using Selenium Web Driver

Try to get text From Pop Up: String ...READ MORE

answered Jul 18, 2018 in Selenium by Samarpit
• 5,130 points
82 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
273 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
639 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
264 views
0 votes
2 answers

Python: Using an existing google chrome profile with selenium chrome web driver

The problem is with the string "C:\Users\Eric\Desktop\beeline.txt" Here, \U starts an ...READ MORE

answered May 23 in Selenium by shinio llahsra
2,215 views
0 votes
1 answer

How to resolve Pycharm Referenced Error with Import Selenium Web driver?

Below will help: Pycharm > Preferences > Project ...READ MORE

answered Jun 26, 2018 in Selenium by Samarpit
• 5,130 points
1,508 views